whoami7 - Manager
:
/
home
/
kckglobal
/
www
/
portal
/
vendor
/
mailchimp
/
marketing
/
lib
/
Api
/
Upload File:
files >> /home/kckglobal/www/portal/vendor/mailchimp/marketing/lib/Api/AutomationsApi.php
<?php /** * AutomationsApi * PHP version 5 * * @category Class * @package MailchimpMarketing * @author Swagger Codegen team * @link https://github.com/swagger-api/swagger-codegen */ /** * Mailchimp Marketing API * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * OpenAPI spec version: 3.0.80 * Contact: apihelp@mailchimp.com * Generated by: https://github.com/swagger-api/swagger-codegen.git * Swagger Codegen version: 2.4.12 */ /** * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen * Do not edit the class manually. */ namespace MailchimpMarketing\Api; use GuzzleHttp\Client; use GuzzleHttp\ClientInterface; use GuzzleHttp\Exception\RequestException; use GuzzleHttp\Psr7\MultipartStream; use GuzzleHttp\Psr7\Query; use GuzzleHttp\Psr7\Request; use GuzzleHttp\RequestOptions; use MailchimpMarketing\ApiException; use MailchimpMarketing\Configuration; use MailchimpMarketing\HeaderSelector; use MailchimpMarketing\ObjectSerializer; class AutomationsApi { protected $client; protected $config; protected $headerSelector; public function __construct(Configuration $config = null) { $this->client = new Client([ 'defaults' => [ 'timeout' => 120.0 ] ]); $this->headerSelector = new HeaderSelector(); $this->config = $config ?: new Configuration(); } public function getConfig() { return $this->config; } public function archive($workflow_id) { $this->archiveWithHttpInfo($workflow_id); } public function archiveWithHttpInfo($workflow_id) { $request = $this->archiveRequest($workflow_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function archiveRequest($workflow_id) { // verify the required parameter 'workflow_id' is set if ($workflow_id === null || (is_array($workflow_id) && count($workflow_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $workflow_id when calling ' ); } $resourcePath = '/automations/{workflow_id}/actions/archive'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($workflow_id !== null) { $resourcePath = str_replace( '{' . 'workflow_id' . '}', ObjectSerializer::toPathValue($workflow_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function deleteWorkflowEmail($workflow_id, $workflow_email_id) { $this->deleteWorkflowEmailWithHttpInfo($workflow_id, $workflow_email_id); } public function deleteWorkflowEmailWithHttpInfo($workflow_id, $workflow_email_id) { $request = $this->deleteWorkflowEmailRequest($workflow_id, $workflow_email_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function deleteWorkflowEmailRequest($workflow_id, $workflow_email_id) { // verify the required parameter 'workflow_id' is set if ($workflow_id === null || (is_array($workflow_id) && count($workflow_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $workflow_id when calling ' ); } // verify the required parameter 'workflow_email_id' is set if ($workflow_email_id === null || (is_array($workflow_email_id) && count($workflow_email_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $workflow_email_id when calling ' ); } $resourcePath = '/automations/{workflow_id}/emails/{workflow_email_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($workflow_id !== null) { $resourcePath = str_replace( '{' . 'workflow_id' . '}', ObjectSerializer::toPathValue($workflow_id), $resourcePath ); } // path params if ($workflow_email_id !== null) { $resourcePath = str_replace( '{' . 'workflow_email_id' . '}', ObjectSerializer::toPathValue($workflow_email_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'DELETE', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function list($count = '10', $offset = '0', $fields = null, $exclude_fields = null, $before_create_time = null, $since_create_time = null, $before_start_time = null, $since_start_time = null, $status = null) { $response = $this->listWithHttpInfo($count, $offset, $fields, $exclude_fields, $before_create_time, $since_create_time, $before_start_time, $since_start_time, $status); return $response; } public function listWithHttpInfo($count = '10', $offset = '0', $fields = null, $exclude_fields = null, $before_create_time = null, $since_create_time = null, $before_start_time = null, $since_start_time = null, $status = null) { $request = $this->listRequest($count, $offset, $fields, $exclude_fields, $before_create_time, $since_create_time, $before_start_time, $since_start_time, $status); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function listRequest($count = '10', $offset = '0', $fields = null, $exclude_fields = null, $before_create_time = null, $since_create_time = null, $before_start_time = null, $since_start_time = null, $status = null) { if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling AutomationsApi., must be smaller than or equal to 1000.'); } $resourcePath = '/automations'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($before_create_time !== null) { $queryParams['before_create_time'] = ObjectSerializer::toQueryValue($before_create_time); } // query params if ($since_create_time !== null) { $queryParams['since_create_time'] = ObjectSerializer::toQueryValue($since_create_time); } // query params if ($before_start_time !== null) { $queryParams['before_start_time'] = ObjectSerializer::toQueryValue($before_start_time); } // query params if ($since_start_time !== null) { $queryParams['since_start_time'] = ObjectSerializer::toQueryValue($since_start_time); } // query params if ($status !== null) { $queryParams['status'] = ObjectSerializer::toQueryValue($status); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function get($workflow_id, $fields = null, $exclude_fields = null) { $response = $this->getWithHttpInfo($workflow_id, $fields, $exclude_fields); return $response; } public function getWithHttpInfo($workflow_id, $fields = null, $exclude_fields = null) { $request = $this->getRequest($workflow_id, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getRequest($workflow_id, $fields = null, $exclude_fields = null) { // verify the required parameter 'workflow_id' is set if ($workflow_id === null || (is_array($workflow_id) && count($workflow_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $workflow_id when calling ' ); } $resourcePath = '/automations/{workflow_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($workflow_id !== null) { $resourcePath = str_replace( '{' . 'workflow_id' . '}', ObjectSerializer::toPathValue($workflow_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function listAllWorkflowEmails($workflow_id) { $response = $this->listAllWorkflowEmailsWithHttpInfo($workflow_id); return $response; } public function listAllWorkflowEmailsWithHttpInfo($workflow_id) { $request = $this->listAllWorkflowEmailsRequest($workflow_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function listAllWorkflowEmailsRequest($workflow_id) { // verify the required parameter 'workflow_id' is set if ($workflow_id === null || (is_array($workflow_id) && count($workflow_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $workflow_id when calling ' ); } $resourcePath = '/automations/{workflow_id}/emails'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($workflow_id !== null) { $resourcePath = str_replace( '{' . 'workflow_id' . '}', ObjectSerializer::toPathValue($workflow_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getWorkflowEmail($workflow_id, $workflow_email_id) { $response = $this->getWorkflowEmailWithHttpInfo($workflow_id, $workflow_email_id); return $response; } public function getWorkflowEmailWithHttpInfo($workflow_id, $workflow_email_id) { $request = $this->getWorkflowEmailRequest($workflow_id, $workflow_email_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getWorkflowEmailRequest($workflow_id, $workflow_email_id) { // verify the required parameter 'workflow_id' is set if ($workflow_id === null || (is_array($workflow_id) && count($workflow_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $workflow_id when calling ' ); } // verify the required parameter 'workflow_email_id' is set if ($workflow_email_id === null || (is_array($workflow_email_id) && count($workflow_email_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $workflow_email_id when calling ' ); } $resourcePath = '/automations/{workflow_id}/emails/{workflow_email_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($workflow_id !== null) { $resourcePath = str_replace( '{' . 'workflow_id' . '}', ObjectSerializer::toPathValue($workflow_id), $resourcePath ); } // path params if ($workflow_email_id !== null) { $resourcePath = str_replace( '{' . 'workflow_email_id' . '}', ObjectSerializer::toPathValue($workflow_email_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getWorkflowEmailSubscriberQueue($workflow_id, $workflow_email_id) { $response = $this->getWorkflowEmailSubscriberQueueWithHttpInfo($workflow_id, $workflow_email_id); return $response; } public function getWorkflowEmailSubscriberQueueWithHttpInfo($workflow_id, $workflow_email_id) { $request = $this->getWorkflowEmailSubscriberQueueRequest($workflow_id, $workflow_email_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getWorkflowEmailSubscriberQueueRequest($workflow_id, $workflow_email_id) { // verify the required parameter 'workflow_id' is set if ($workflow_id === null || (is_array($workflow_id) && count($workflow_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $workflow_id when calling ' ); } // verify the required parameter 'workflow_email_id' is set if ($workflow_email_id === null || (is_array($workflow_email_id) && count($workflow_email_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $workflow_email_id when calling ' ); } $resourcePath = '/automations/{workflow_id}/emails/{workflow_email_id}/queue'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($workflow_id !== null) { $resourcePath = str_replace( '{' . 'workflow_id' . '}', ObjectSerializer::toPathValue($workflow_id), $resourcePath ); } // path params if ($workflow_email_id !== null) { $resourcePath = str_replace( '{' . 'workflow_email_id' . '}', ObjectSerializer::toPathValue($workflow_email_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getWorkflowEmailSubscriber($workflow_id, $workflow_email_id, $subscriber_hash) { $response = $this->getWorkflowEmailSubscriberWithHttpInfo($workflow_id, $workflow_email_id, $subscriber_hash); return $response; } public function getWorkflowEmailSubscriberWithHttpInfo($workflow_id, $workflow_email_id, $subscriber_hash) { $request = $this->getWorkflowEmailSubscriberRequest($workflow_id, $workflow_email_id, $subscriber_hash); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getWorkflowEmailSubscriberRequest($workflow_id, $workflow_email_id, $subscriber_hash) { // verify the required parameter 'workflow_id' is set if ($workflow_id === null || (is_array($workflow_id) && count($workflow_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $workflow_id when calling ' ); } // verify the required parameter 'workflow_email_id' is set if ($workflow_email_id === null || (is_array($workflow_email_id) && count($workflow_email_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $workflow_email_id when calling ' ); } // verify the required parameter 'subscriber_hash' is set if ($subscriber_hash === null || (is_array($subscriber_hash) && count($subscriber_hash) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $subscriber_hash when calling ' ); } $resourcePath = '/automations/{workflow_id}/emails/{workflow_email_id}/queue/{subscriber_hash}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($workflow_id !== null) { $resourcePath = str_replace( '{' . 'workflow_id' . '}', ObjectSerializer::toPathValue($workflow_id), $resourcePath ); } // path params if ($workflow_email_id !== null) { $resourcePath = str_replace( '{' . 'workflow_email_id' . '}', ObjectSerializer::toPathValue($workflow_email_id), $resourcePath ); } // path params if ($subscriber_hash !== null) { $resourcePath = str_replace( '{' . 'subscriber_hash' . '}', ObjectSerializer::toPathValue($subscriber_hash), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function listWorkflowEmailSubscribersRemoved($workflow_id) { $response = $this->listWorkflowEmailSubscribersRemovedWithHttpInfo($workflow_id); return $response; } public function listWorkflowEmailSubscribersRemovedWithHttpInfo($workflow_id) { $request = $this->listWorkflowEmailSubscribersRemovedRequest($workflow_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function listWorkflowEmailSubscribersRemovedRequest($workflow_id) { // verify the required parameter 'workflow_id' is set if ($workflow_id === null || (is_array($workflow_id) && count($workflow_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $workflow_id when calling ' ); } $resourcePath = '/automations/{workflow_id}/removed-subscribers'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($workflow_id !== null) { $resourcePath = str_replace( '{' . 'workflow_id' . '}', ObjectSerializer::toPathValue($workflow_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getRemovedWorkflowEmailSubscriber($workflow_id, $subscriber_hash) { $response = $this->getRemovedWorkflowEmailSubscriberWithHttpInfo($workflow_id, $subscriber_hash); return $response; } public function getRemovedWorkflowEmailSubscriberWithHttpInfo($workflow_id, $subscriber_hash) { $request = $this->getRemovedWorkflowEmailSubscriberRequest($workflow_id, $subscriber_hash); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getRemovedWorkflowEmailSubscriberRequest($workflow_id, $subscriber_hash) { // verify the required parameter 'workflow_id' is set if ($workflow_id === null || (is_array($workflow_id) && count($workflow_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $workflow_id when calling ' ); } // verify the required parameter 'subscriber_hash' is set if ($subscriber_hash === null || (is_array($subscriber_hash) && count($subscriber_hash) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $subscriber_hash when calling ' ); } $resourcePath = '/automations/{workflow_id}/removed-subscribers/{subscriber_hash}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($workflow_id !== null) { $resourcePath = str_replace( '{' . 'workflow_id' . '}', ObjectSerializer::toPathValue($workflow_id), $resourcePath ); } // path params if ($subscriber_hash !== null) { $resourcePath = str_replace( '{' . 'subscriber_hash' . '}', ObjectSerializer::toPathValue($subscriber_hash), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function updateWorkflowEmail($workflow_id, $workflow_email_id, $body) { $response = $this->updateWorkflowEmailWithHttpInfo($workflow_id, $workflow_email_id, $body); return $response; } public function updateWorkflowEmailWithHttpInfo($workflow_id, $workflow_email_id, $body) { $request = $this->updateWorkflowEmailRequest($workflow_id, $workflow_email_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function updateWorkflowEmailRequest($workflow_id, $workflow_email_id, $body) { // verify the required parameter 'workflow_id' is set if ($workflow_id === null || (is_array($workflow_id) && count($workflow_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $workflow_id when calling ' ); } // verify the required parameter 'workflow_email_id' is set if ($workflow_email_id === null || (is_array($workflow_email_id) && count($workflow_email_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $workflow_email_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/automations/{workflow_id}/emails/{workflow_email_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($workflow_id !== null) { $resourcePath = str_replace( '{' . 'workflow_id' . '}', ObjectSerializer::toPathValue($workflow_id), $resourcePath ); } // path params if ($workflow_email_id !== null) { $resourcePath = str_replace( '{' . 'workflow_email_id' . '}', ObjectSerializer::toPathValue($workflow_email_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'PATCH', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function create($body) { $response = $this->createWithHttpInfo($body); return $response; } public function createWithHttpInfo($body) { $request = $this->createRequest($body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function createRequest($body) { // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/automations'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function pauseAllEmails($workflow_id) { $this->pauseAllEmailsWithHttpInfo($workflow_id); } public function pauseAllEmailsWithHttpInfo($workflow_id) { $request = $this->pauseAllEmailsRequest($workflow_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function pauseAllEmailsRequest($workflow_id) { // verify the required parameter 'workflow_id' is set if ($workflow_id === null || (is_array($workflow_id) && count($workflow_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $workflow_id when calling ' ); } $resourcePath = '/automations/{workflow_id}/actions/pause-all-emails'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($workflow_id !== null) { $resourcePath = str_replace( '{' . 'workflow_id' . '}', ObjectSerializer::toPathValue($workflow_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function startAllEmails($workflow_id) { $this->startAllEmailsWithHttpInfo($workflow_id); } public function startAllEmailsWithHttpInfo($workflow_id) { $request = $this->startAllEmailsRequest($workflow_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function startAllEmailsRequest($workflow_id) { // verify the required parameter 'workflow_id' is set if ($workflow_id === null || (is_array($workflow_id) && count($workflow_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $workflow_id when calling ' ); } $resourcePath = '/automations/{workflow_id}/actions/start-all-emails'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($workflow_id !== null) { $resourcePath = str_replace( '{' . 'workflow_id' . '}', ObjectSerializer::toPathValue($workflow_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function pauseWorkflowEmail($workflow_id, $workflow_email_id) { $this->pauseWorkflowEmailWithHttpInfo($workflow_id, $workflow_email_id); } public function pauseWorkflowEmailWithHttpInfo($workflow_id, $workflow_email_id) { $request = $this->pauseWorkflowEmailRequest($workflow_id, $workflow_email_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function pauseWorkflowEmailRequest($workflow_id, $workflow_email_id) { // verify the required parameter 'workflow_id' is set if ($workflow_id === null || (is_array($workflow_id) && count($workflow_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $workflow_id when calling ' ); } // verify the required parameter 'workflow_email_id' is set if ($workflow_email_id === null || (is_array($workflow_email_id) && count($workflow_email_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $workflow_email_id when calling ' ); } $resourcePath = '/automations/{workflow_id}/emails/{workflow_email_id}/actions/pause'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($workflow_id !== null) { $resourcePath = str_replace( '{' . 'workflow_id' . '}', ObjectSerializer::toPathValue($workflow_id), $resourcePath ); } // path params if ($workflow_email_id !== null) { $resourcePath = str_replace( '{' . 'workflow_email_id' . '}', ObjectSerializer::toPathValue($workflow_email_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function startWorkflowEmail($workflow_id, $workflow_email_id) { $this->startWorkflowEmailWithHttpInfo($workflow_id, $workflow_email_id); } public function startWorkflowEmailWithHttpInfo($workflow_id, $workflow_email_id) { $request = $this->startWorkflowEmailRequest($workflow_id, $workflow_email_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function startWorkflowEmailRequest($workflow_id, $workflow_email_id) { // verify the required parameter 'workflow_id' is set if ($workflow_id === null || (is_array($workflow_id) && count($workflow_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $workflow_id when calling ' ); } // verify the required parameter 'workflow_email_id' is set if ($workflow_email_id === null || (is_array($workflow_email_id) && count($workflow_email_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $workflow_email_id when calling ' ); } $resourcePath = '/automations/{workflow_id}/emails/{workflow_email_id}/actions/start'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($workflow_id !== null) { $resourcePath = str_replace( '{' . 'workflow_id' . '}', ObjectSerializer::toPathValue($workflow_id), $resourcePath ); } // path params if ($workflow_email_id !== null) { $resourcePath = str_replace( '{' . 'workflow_email_id' . '}', ObjectSerializer::toPathValue($workflow_email_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function addWorkflowEmailSubscriber($workflow_id, $workflow_email_id, $body) { $response = $this->addWorkflowEmailSubscriberWithHttpInfo($workflow_id, $workflow_email_id, $body); return $response; } public function addWorkflowEmailSubscriberWithHttpInfo($workflow_id, $workflow_email_id, $body) { $request = $this->addWorkflowEmailSubscriberRequest($workflow_id, $workflow_email_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function addWorkflowEmailSubscriberRequest($workflow_id, $workflow_email_id, $body) { // verify the required parameter 'workflow_id' is set if ($workflow_id === null || (is_array($workflow_id) && count($workflow_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $workflow_id when calling ' ); } // verify the required parameter 'workflow_email_id' is set if ($workflow_email_id === null || (is_array($workflow_email_id) && count($workflow_email_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $workflow_email_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/automations/{workflow_id}/emails/{workflow_email_id}/queue'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($workflow_id !== null) { $resourcePath = str_replace( '{' . 'workflow_id' . '}', ObjectSerializer::toPathValue($workflow_id), $resourcePath ); } // path params if ($workflow_email_id !== null) { $resourcePath = str_replace( '{' . 'workflow_email_id' . '}', ObjectSerializer::toPathValue($workflow_email_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function removeWorkflowEmailSubscriber($workflow_id, $body) { $response = $this->removeWorkflowEmailSubscriberWithHttpInfo($workflow_id, $body); return $response; } public function removeWorkflowEmailSubscriberWithHttpInfo($workflow_id, $body) { $request = $this->removeWorkflowEmailSubscriberRequest($workflow_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function removeWorkflowEmailSubscriberRequest($workflow_id, $body) { // verify the required parameter 'workflow_id' is set if ($workflow_id === null || (is_array($workflow_id) && count($workflow_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $workflow_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/automations/{workflow_id}/removed-subscribers'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($workflow_id !== null) { $resourcePath = str_replace( '{' . 'workflow_id' . '}', ObjectSerializer::toPathValue($workflow_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } protected function createHttpClientOption() { $options = []; if ($this->config->getDebug()) { $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); if (!$options[RequestOptions::DEBUG]) { throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); } } if ($this->config->getTimeout()) { $options[RequestOptions::TIMEOUT] = $this->config->getTimeout(); } return $options; } }
Copyright ©2021 || Defacer Indonesia