<?php
/**
* ReportsApi
* 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.27
* 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\Request;
use GuzzleHttp\RequestOptions;
use MailchimpMarketing\ApiException;
use MailchimpMarketing\Configuration;
use MailchimpMarketing\HeaderSelector;
use MailchimpMarketing\ObjectSerializer;
class ReportsApi
{
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 getAllCampaignReports($fields = null, $exclude_fields = null, $count = '10', $offset = '0', $type = null, $before_send_time = null, $since_send_time = null)
{
$response = $this->getAllCampaignReportsWithHttpInfo($fields, $exclude_fields, $count, $offset, $type, $before_send_time, $since_send_time);
return $response;
}
public function getAllCampaignReportsWithHttpInfo($fields = null, $exclude_fields = null, $count = '10', $offset = '0', $type = null, $before_send_time = null, $since_send_time = null)
{
$request = $this->getAllCampaignReportsRequest($fields, $exclude_fields, $count, $offset, $type, $before_send_time, $since_send_time);
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 getAllCampaignReportsRequest($fields = null, $exclude_fields = null, $count = '10', $offset = '0', $type = null, $before_send_time = null, $since_send_time = null)
{
if ($count !== null && $count > 1000) {
throw new \InvalidArgumentException('invalid value for "$count" when calling ReportsApi., must be smaller than or equal to 1000.');
}
$resourcePath = '/reports';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if (is_array($fields)) {
$queryParams['fields'] = $fields;
} else
if ($fields !== null) {
$queryParams['fields'] = ObjectSerializer::toQueryValue($fields);
}
// query params
if (is_array($exclude_fields)) {
$queryParams['exclude_fields'] = $exclude_fields;
} else
if ($exclude_fields !== null) {
$queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields);
}
// query params
if ($count !== null) {
$queryParams['count'] = ObjectSerializer::toQueryValue($count);
}
// query params
if ($offset !== null) {
$queryParams['offset'] = ObjectSerializer::toQueryValue($offset);
}
// query params
if ($type !== null) {
$queryParams['type'] = ObjectSerializer::toQueryValue($type);
}
// query params
if ($before_send_time !== null) {
$queryParams['before_send_time'] = ObjectSerializer::toQueryValue($before_send_time);
}
// query params
if ($since_send_time !== null) {
$queryParams['since_send_time'] = ObjectSerializer::toQueryValue($since_send_time);
}
// 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 = \GuzzleHttp\Psr7\build_query($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 = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
public function getCampaignReport($campaign_id, $fields = null, $exclude_fields = null)
{
$response = $this->getCampaignReportWithHttpInfo($campaign_id, $fields, $exclude_fields);
return $response;
}
public function getCampaignReportWithHttpInfo($campaign_id, $fields = null, $exclude_fields = null)
{
$request = $this->getCampaignReportRequest($campaign_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 getCampaignReportRequest($campaign_id, $fields = null, $exclude_fields = null)
{
// verify the required parameter 'campaign_id' is set
if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $campaign_id when calling '
);
}
$resourcePath = '/reports/{campaign_id}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if (is_array($fields)) {
$queryParams['fields'] = $fields;
} else
if ($fields !== null) {
$queryParams['fields'] = ObjectSerializer::toQueryValue($fields);
}
// query params
if (is_array($exclude_fields)) {
$queryParams['exclude_fields'] = $exclude_fields;
} else
if ($exclude_fields !== null) {
$queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields);
}
// path params
if ($campaign_id !== null) {
$resourcePath = str_replace(
'{' . 'campaign_id' . '}',
ObjectSerializer::toPathValue($campaign_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 = \GuzzleHttp\Psr7\build_query($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 = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
public function getCampaignAbuseReports($campaign_id, $fields = null, $exclude_fields = null)
{
$response = $this->getCampaignAbuseReportsWithHttpInfo($campaign_id, $fields, $exclude_fields);
return $response;
}
public function getCampaignAbuseReportsWithHttpInfo($campaign_id, $fields = null, $exclude_fields = null)
{
$request = $this->getCampaignAbuseReportsRequest($campaign_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 getCampaignAbuseReportsRequest($campaign_id, $fields = null, $exclude_fields = null)
{
// verify the required parameter 'campaign_id' is set
if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $campaign_id when calling '
);
}
$resourcePath = '/reports/{campaign_id}/abuse-reports';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if (is_array($fields)) {
$queryParams['fields'] = $fields;
} else
if ($fields !== null) {
$queryParams['fields'] = ObjectSerializer::toQueryValue($fields);
}
// query params
if (is_array($exclude_fields)) {
$queryParams['exclude_fields'] = $exclude_fields;
} else
if ($exclude_fields !== null) {
$queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields);
}
// path params
if ($campaign_id !== null) {
$resourcePath = str_replace(
'{' . 'campaign_id' . '}',
ObjectSerializer::toPathValue($campaign_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 = \GuzzleHttp\Psr7\build_query($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 = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
public function getCampaignAbuseReport($campaign_id, $report_id, $fields = null, $exclude_fields = null)
{
$response = $this->getCampaignAbuseReportWithHttpInfo($campaign_id, $report_id, $fields, $exclude_fields);
return $response;
}
public function getCampaignAbuseReportWithHttpInfo($campaign_id, $report_id, $fields = null, $exclude_fields = null)
{
$request = $this->getCampaignAbuseReportRequest($campaign_id, $report_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 getCampaignAbuseReportRequest($campaign_id, $report_id, $fields = null, $exclude_fields = null)
{
// verify the required parameter 'campaign_id' is set
if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $campaign_id when calling '
);
}
// verify the required parameter 'report_id' is set
if ($report_id === null || (is_array($report_id) && count($report_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $report_id when calling '
);
}
$resourcePath = '/reports/{campaign_id}/abuse-reports/{report_id}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if (is_array($fields)) {
$queryParams['fields'] = $fields;
} else
if ($fields !== null) {
$queryParams['fields'] = ObjectSerializer::toQueryValue($fields);
}
// query params
if (is_array($exclude_fields)) {
$queryParams['exclude_fields'] = $exclude_fields;
} else
if ($exclude_fields !== null) {
$queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields);
}
// path params
if ($campaign_id !== null) {
$resourcePath = str_replace(
'{' . 'campaign_id' . '}',
ObjectSerializer::toPathValue($campaign_id),
$resourcePath
);
}
// path params
if ($report_id !== null) {
$resourcePath = str_replace(
'{' . 'report_id' . '}',
ObjectSerializer::toPathValue($report_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 = \GuzzleHttp\Psr7\build_query($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 = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
public function getCampaignAdvice($campaign_id, $fields = null, $exclude_fields = null)
{
$response = $this->getCampaignAdviceWithHttpInfo($campaign_id, $fields, $exclude_fields);
return $response;
}
public function getCampaignAdviceWithHttpInfo($campaign_id, $fields = null, $exclude_fields = null)
{
$request = $this->getCampaignAdviceRequest($campaign_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 getCampaignAdviceRequest($campaign_id, $fields = null, $exclude_fields = null)
{
// verify the required parameter 'campaign_id' is set
if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $campaign_id when calling '
);
}
$resourcePath = '/reports/{campaign_id}/advice';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if (is_array($fields)) {
$queryParams['fields'] = $fields;
} else
if ($fields !== null) {
$queryParams['fields'] = ObjectSerializer::toQueryValue($fields);
}
// query params
if (is_array($exclude_fields)) {
$queryParams['exclude_fields'] = $exclude_fields;
} else
if ($exclude_fields !== null) {
$queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields);
}
// path params
if ($campaign_id !== null) {
$resourcePath = str_replace(
'{' . 'campaign_id' . '}',
ObjectSerializer::toPathValue($campaign_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 = \GuzzleHttp\Psr7\build_query($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 = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
public function getCampaignClickDetails($campaign_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0')
{
$response = $this->getCampaignClickDetailsWithHttpInfo($campaign_id, $fields, $exclude_fields, $count, $offset);
return $response;
}
public function getCampaignClickDetailsWithHttpInfo($campaign_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0')
{
$request = $this->getCampaignClickDetailsRequest($campaign_id, $fields, $exclude_fields, $count, $offset);
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 getCampaignClickDetailsRequest($campaign_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0')
{
// verify the required parameter 'campaign_id' is set
if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $campaign_id when calling '
);
}
if ($count !== null && $count > 1000) {
throw new \InvalidArgumentException('invalid value for "$count" when calling ReportsApi., must be smaller than or equal to 1000.');
}
$resourcePath = '/reports/{campaign_id}/click-details';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if (is_array($fields)) {
$queryParams['fields'] = $fields;
} else
if ($fields !== null) {
$queryParams['fields'] = ObjectSerializer::toQueryValue($fields);
}
// query params
if (is_array($exclude_fields)) {
$queryParams['exclude_fields'] = $exclude_fields;
} else
if ($exclude_fields !== null) {
$queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields);
}
// query params
if ($count !== null) {
$queryParams['count'] = ObjectSerializer::toQueryValue($count);
}
// query params
if ($offset !== null) {
$queryParams['offset'] = ObjectSerializer::toQueryValue($offset);
}
// path params
if ($campaign_id !== null) {
$resourcePath = str_replace(
'{' . 'campaign_id' . '}',
ObjectSerializer::toPathValue($campaign_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 = \GuzzleHttp\Psr7\build_query($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 = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
public function getCampaignClickDetailsForLink($campaign_id, $link_id, $fields = null, $exclude_fields = null)
{
$response = $this->getCampaignClickDetailsForLinkWithHttpInfo($campaign_id, $link_id, $fields, $exclude_fields);
return $response;
}
public function getCampaignClickDetailsForLinkWithHttpInfo($campaign_id, $link_id, $fields = null, $exclude_fields = null)
{
$request = $this->getCampaignClickDetailsForLinkRequest($campaign_id, $link_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 getCampaignClickDetailsForLinkRequest($campaign_id, $link_id, $fields = null, $exclude_fields = null)
{
// verify the required parameter 'campaign_id' is set
if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $campaign_id when calling '
);
}
// verify the required parameter 'link_id' is set
if ($link_id === null || (is_array($link_id) && count($link_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $link_id when calling '
);
}
$resourcePath = '/reports/{campaign_id}/click-details/{link_id}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if (is_array($fields)) {
$queryParams['fields'] = $fields;
} else
if ($fields !== null) {
$queryParams['fields'] = ObjectSerializer::toQueryValue($fields);
}
// query params
if (is_array($exclude_fields)) {
$queryParams['exclude_fields'] = $exclude_fields;
} else
if ($exclude_fields !== null) {
$queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields);
}
// path params
if ($campaign_id !== null) {
$resourcePath = str_replace(
'{' . 'campaign_id' . '}',
ObjectSerializer::toPathValue($campaign_id),
$resourcePath
);
}
// path params
if ($link_id !== null) {
$resourcePath = str_replace(
'{' . 'link_id' . '}',
ObjectSerializer::toPathValue($link_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 = \GuzzleHttp\Psr7\build_query($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 = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
public function getSubscribersInfo($campaign_id, $link_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0')
{
$response = $this->getSubscribersInfoWithHttpInfo($campaign_id, $link_id, $fields, $exclude_fields, $count, $offset);
return $response;
}
public function getSubscribersInfoWithHttpInfo($campaign_id, $link_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0')
{
$request = $this->getSubscribersInfoRequest($campaign_id, $link_id, $fields, $exclude_fields, $count, $offset);
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 getSubscribersInfoRequest($campaign_id, $link_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0')
{
// verify the required parameter 'campaign_id' is set
if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $campaign_id when calling '
);
}
// verify the required parameter 'link_id' is set
if ($link_id === null || (is_array($link_id) && count($link_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $link_id when calling '
);
}
if ($count !== null && $count > 1000) {
throw new \InvalidArgumentException('invalid value for "$count" when calling ReportsApi., must be smaller than or equal to 1000.');
}
$resourcePath = '/reports/{campaign_id}/click-details/{link_id}/members';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if (is_array($fields)) {
$queryParams['fields'] = $fields;
} else
if ($fields !== null) {
$queryParams['fields'] = ObjectSerializer::toQueryValue($fields);
}
// query params
if (is_array($exclude_fields)) {
$queryParams['exclude_fields'] = $exclude_fields;
} else
if ($exclude_fields !== null) {
$queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields);
}
// query params
if ($count !== null) {
$queryParams['count'] = ObjectSerializer::toQueryValue($count);
}
// query params
if ($offset !== null) {
$queryParams['offset'] = ObjectSerializer::toQueryValue($offset);
}
// path params
if ($campaign_id !== null) {
$resourcePath = str_replace(
'{' . 'campaign_id' . '}',
ObjectSerializer::toPathValue($campaign_id),
$resourcePath
);
}
// path params
if ($link_id !== null) {
$resourcePath = str_replace(
'{' . 'link_id' . '}',
ObjectSerializer::toPathValue($link_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 = \GuzzleHttp\Psr7\build_query($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 = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
public function getSubscriberInfo($campaign_id, $link_id, $subscriber_hash, $fields = null, $exclude_fields = null)
{
$response = $this->getSubscriberInfoWithHttpInfo($campaign_id, $link_id, $subscriber_hash, $fields, $exclude_fields);
return $response;
}
public function getSubscriberInfoWithHttpInfo($campaign_id, $link_id, $subscriber_hash, $fields = null, $exclude_fields = null)
{
$request = $this->getSubscriberInfoRequest($campaign_id, $link_id, $subscriber_hash, $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 getSubscriberInfoRequest($campaign_id, $link_id, $subscriber_hash, $fields = null, $exclude_fields = null)
{
// verify the required parameter 'campaign_id' is set
if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $campaign_id when calling '
);
}
// verify the required parameter 'link_id' is set
if ($link_id === null || (is_array($link_id) && count($link_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $link_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 = '/reports/{campaign_id}/click-details/{link_id}/members/{subscriber_hash}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if (is_array($fields)) {
$queryParams['fields'] = $fields;
} else
if ($fields !== null) {
$queryParams['fields'] = ObjectSerializer::toQueryValue($fields);
}
// query params
if (is_array($exclude_fields)) {
$queryParams['exclude_fields'] = $exclude_fields;
} else
if ($exclude_fields !== null) {
$queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields);
}
// path params
if ($campaign_id !== null) {
$resourcePath = str_replace(
'{' . 'campaign_id' . '}',
ObjectSerializer::toPathValue($campaign_id),
$resourcePath
);
}
// path params
if ($link_id !== null) {
$resourcePath = str_replace(
'{' . 'link_id' . '}',
ObjectSerializer::toPathValue($link_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 = \GuzzleHttp\Psr7\build_query($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 = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
public function getDomainPerformanceForCampaign($campaign_id, $fields = null, $exclude_fields = null)
{
$response = $this->getDomainPerformanceForCampaignWithHttpInfo($campaign_id, $fields, $exclude_fields);
return $response;
}
public function getDomainPerformanceForCampaignWithHttpInfo($campaign_id, $fields = null, $exclude_fields = null)
{
$request = $this->getDomainPerformanceForCampaignRequest($campaign_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 getDomainPerformanceForCampaignRequest($campaign_id, $fields = null, $exclude_fields = null)
{
// verify the required parameter 'campaign_id' is set
if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $campaign_id when calling '
);
}
$resourcePath = '/reports/{campaign_id}/domain-performance';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if (is_array($fields)) {
$queryParams['fields'] = $fields;
} else
if ($fields !== null) {
$queryParams['fields'] = ObjectSerializer::toQueryValue($fields);
}
// query params
if (is_array($exclude_fields)) {
$queryParams['exclude_fields'] = $exclude_fields;
} else
if ($exclude_fields !== null) {
$queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields);
}
// path params
if ($campaign_id !== null) {
$resourcePath = str_replace(
'{' . 'campaign_id' . '}',
ObjectSerializer::toPathValue($campaign_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 = \GuzzleHttp\Psr7\build_query($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 = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
public function getEcommerceProductActivityForCampaign($campaign_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0', $sort_field = null)
{
$response = $this->getEcommerceProductActivityForCampaignWithHttpInfo($campaign_id, $fields, $exclude_fields, $count, $offset, $sort_field);
return $response;
}
public function getEcommerceProductActivityForCampaignWithHttpInfo($campaign_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0', $sort_field = null)
{
$request = $this->getEcommerceProductActivityForCampaignRequest($campaign_id, $fields, $exclude_fields, $count, $offset, $sort_field);
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 getEcommerceProductActivityForCampaignRequest($campaign_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0', $sort_field = null)
{
// verify the required parameter 'campaign_id' is set
if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $campaign_id when calling '
);
}
if ($count !== null && $count > 1000) {
throw new \InvalidArgumentException('invalid value for "$count" when calling ReportsApi., must be smaller than or equal to 1000.');
}
$resourcePath = '/reports/{campaign_id}/ecommerce-product-activity';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if (is_array($fields)) {
$queryParams['fields'] = $fields;
} else
if ($fields !== null) {
$queryParams['fields'] = ObjectSerializer::toQueryValue($fields);
}
// query params
if (is_array($exclude_fields)) {
$queryParams['exclude_fields'] = $exclude_fields;
} else
if ($exclude_fields !== null) {
$queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields);
}
// query params
if ($count !== null) {
$queryParams['count'] = ObjectSerializer::toQueryValue($count);
}
// query params
if ($offset !== null) {
$queryParams['offset'] = ObjectSerializer::toQueryValue($offset);
}
// query params
if ($sort_field !== null) {
$queryParams['sort_field'] = ObjectSerializer::toQueryValue($sort_field);
}
// path params
if ($campaign_id !== null) {
$resourcePath = str_replace(
'{' . 'campaign_id' . '}',
ObjectSerializer::toPathValue($campaign_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 = \GuzzleHttp\Psr7\build_query($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 = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
public function getEepurlActivityForCampaign($campaign_id, $fields = null, $exclude_fields = null)
{
$response = $this->getEepurlActivityForCampaignWithHttpInfo($campaign_id, $fields, $exclude_fields);
return $response;
}
public function getEepurlActivityForCampaignWithHttpInfo($campaign_id, $fields = null, $exclude_fields = null)
{
$request = $this->getEepurlActivityForCampaignRequest($campaign_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 getEepurlActivityForCampaignRequest($campaign_id, $fields = null, $exclude_fields = null)
{
// verify the required parameter 'campaign_id' is set
if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $campaign_id when calling '
);
}
$resourcePath = '/reports/{campaign_id}/eepurl';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if (is_array($fields)) {
$queryParams['fields'] = $fields;
} else
if ($fields !== null) {
$queryParams['fields'] = ObjectSerializer::toQueryValue($fields);
}
// query params
if (is_array($exclude_fields)) {
$queryParams['exclude_fields'] = $exclude_fields;
} else
if ($exclude_fields !== null) {
$queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields);
}
// path params
if ($campaign_id !== null) {
$resourcePath = str_replace(
'{' . 'campaign_id' . '}',
ObjectSerializer::toPathValue($campaign_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 = \GuzzleHttp\Psr7\build_query($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 = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
public function getEmailActivityForCampaign($campaign_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0', $since = null)
{
$response = $this->getEmailActivityForCampaignWithHttpInfo($campaign_id, $fields, $exclude_fields, $count, $offset, $since);
return $response;
}
public function getEmailActivityForCampaignWithHttpInfo($campaign_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0', $since = null)
{
$request = $this->getEmailActivityForCampaignRequest($campaign_id, $fields, $exclude_fields, $count, $offset, $since);
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 getEmailActivityForCampaignRequest($campaign_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0', $since = null)
{
// verify the required parameter 'campaign_id' is set
if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $campaign_id when calling '
);
}
if ($count !== null && $count > 1000) {
throw new \InvalidArgumentException('invalid value for "$count" when calling ReportsApi., must be smaller than or equal to 1000.');
}
$resourcePath = '/reports/{campaign_id}/email-activity';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if (is_array($fields)) {
$queryParams['fields'] = $fields;
} else
if ($fields !== null) {
$queryParams['fields'] = ObjectSerializer::toQueryValue($fields);
}
// query params
if (is_array($exclude_fields)) {
$queryParams['exclude_fields'] = $exclude_fields;
} else
if ($exclude_fields !== null) {
$queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields);
}
// query params
if ($count !== null) {
$queryParams['count'] = ObjectSerializer::toQueryValue($count);
}
// query params
if ($offset !== null) {
$queryParams['offset'] = ObjectSerializer::toQueryValue($offset);
}
// query params
if ($since !== null) {
$queryParams['since'] = ObjectSerializer::toQueryValue($since);
}
// path params
if ($campaign_id !== null) {
$resourcePath = str_replace(
'{' . 'campaign_id' . '}',
ObjectSerializer::toPathValue($campaign_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 = \GuzzleHttp\Psr7\build_query($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 = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
public function getEmailActivityForSubscriber($campaign_id, $subscriber_hash, $fields = null, $exclude_fields = null, $since = null)
{
$response = $this->getEmailActivityForSubscriberWithHttpInfo($campaign_id, $subscriber_hash, $fields, $exclude_fields, $since);
return $response;
}
public function getEmailActivityForSubscriberWithHttpInfo($campaign_id, $subscriber_hash, $fields = null, $exclude_fields = null, $since = null)
{
$request = $this->getEmailActivityForSubscriberRequest($campaign_id, $subscriber_hash, $fields, $exclude_fields, $since);
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 getEmailActivityForSubscriberRequest($campaign_id, $subscriber_hash, $fields = null, $exclude_fields = null, $since = null)
{
// verify the required parameter 'campaign_id' is set
if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $campaign_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 = '/reports/{campaign_id}/email-activity/{subscriber_hash}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if (is_array($fields)) {
$queryParams['fields'] = $fields;
} else
if ($fields !== null) {
$queryParams['fields'] = ObjectSerializer::toQueryValue($fields);
}
// query params
if (is_array($exclude_fields)) {
$queryParams['exclude_fields'] = $exclude_fields;
} else
if ($exclude_fields !== null) {
$queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields);
}
// query params
if ($since !== null) {
$queryParams['since'] = ObjectSerializer::toQueryValue($since);
}
// path params
if ($campaign_id !== null) {
$resourcePath = str_replace(
'{' . 'campaign_id' . '}',
ObjectSerializer::toPathValue($campaign_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 = \GuzzleHttp\Psr7\build_query($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 = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
public function getLocationsForCampaign($campaign_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0')
{
$response = $this->getLocationsForCampaignWithHttpInfo($campaign_id, $fields, $exclude_fields, $count, $offset);
return $response;
}
public function getLocationsForCampaignWithHttpInfo($campaign_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0')
{
$request = $this->getLocationsForCampaignRequest($campaign_id, $fields, $exclude_fields, $count, $offset);
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 getLocationsForCampaignRequest($campaign_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0')
{
// verify the required parameter 'campaign_id' is set
if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $campaign_id when calling '
);
}
if ($count !== null && $count > 1000) {
throw new \InvalidArgumentException('invalid value for "$count" when calling ReportsApi., must be smaller than or equal to 1000.');
}
$resourcePath = '/reports/{campaign_id}/locations';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if (is_array($fields)) {
$queryParams['fields'] = $fields;
} else
if ($fields !== null) {
$queryParams['fields'] = ObjectSerializer::toQueryValue($fields);
}
// query params
if (is_array($exclude_fields)) {
$queryParams['exclude_fields'] = $exclude_fields;
} else
if ($exclude_fields !== null) {
$queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields);
}
// query params
if ($count !== null) {
$queryParams['count'] = ObjectSerializer::toQueryValue($count);
}
// query params
if ($offset !== null) {
$queryParams['offset'] = ObjectSerializer::toQueryValue($offset);
}
// path params
if ($campaign_id !== null) {
$resourcePath = str_replace(
'{' . 'campaign_id' . '}',
ObjectSerializer::toPathValue($campaign_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 = \GuzzleHttp\Psr7\build_query($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 = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
public function getCampaignOpenDetails($campaign_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0', $since = null)
{
$response = $this->getCampaignOpenDetailsWithHttpInfo($campaign_id, $fields, $exclude_fields, $count, $offset, $since);
return $response;
}
public function getCampaignOpenDetailsWithHttpInfo($campaign_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0', $since = null)
{
$request = $this->getCampaignOpenDetailsRequest($campaign_id, $fields, $exclude_fields, $count, $offset, $since);
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 getCampaignOpenDetailsRequest($campaign_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0', $since = null)
{
// verify the required parameter 'campaign_id' is set
if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $campaign_id when calling '
);
}
if ($count !== null && $count > 1000) {
throw new \InvalidArgumentException('invalid value for "$count" when calling ReportsApi., must be smaller than or equal to 1000.');
}
$resourcePath = '/reports/{campaign_id}/open-details';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if (is_array($fields)) {
$queryParams['fields'] = $fields;
} else
if ($fields !== null) {
$queryParams['fields'] = ObjectSerializer::toQueryValue($fields);
}
// query params
if (is_array($exclude_fields)) {
$queryParams['exclude_fields'] = $exclude_fields;
} else
if ($exclude_fields !== null) {
$queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields);
}
// query params
if ($count !== null) {
$queryParams['count'] = ObjectSerializer::toQueryValue($count);
}
// query params
if ($offset !== null) {
$queryParams['offset'] = ObjectSerializer::toQueryValue($offset);
}
// query params
if ($since !== null) {
$queryParams['since'] = ObjectSerializer::toQueryValue($since);
}
// path params
if ($campaign_id !== null) {
$resourcePath = str_replace(
'{' . 'campaign_id' . '}',
ObjectSerializer::toPathValue($campaign_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 = \GuzzleHttp\Psr7\build_query($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 = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
public function getSubscriberInfoForOpenedCampaign($campaign_id, $subscriber_hash, $fields = null, $exclude_fields = null)
{
$response = $this->getSubscriberInfoForOpenedCampaignWithHttpInfo($campaign_id, $subscriber_hash, $fields, $exclude_fields);
return $response;
}
public function getSubscriberInfoForOpenedCampaignWithHttpInfo($campaign_id, $subscriber_hash, $fields = null, $exclude_fields = null)
{
$request = $this->getSubscriberInfoForOpenedCampaignRequest($campaign_id, $subscriber_hash, $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 getSubscriberInfoForOpenedCampaignRequest($campaign_id, $subscriber_hash, $fields = null, $exclude_fields = null)
{
// verify the required parameter 'campaign_id' is set
if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $campaign_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 = '/reports/{campaign_id}/open-details/{subscriber_hash}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if (is_array($fields)) {
$queryParams['fields'] = $fields;
} else
if ($fields !== null) {
$queryParams['fields'] = ObjectSerializer::toQueryValue($fields);
}
// query params
if (is_array($exclude_fields)) {
$queryParams['exclude_fields'] = $exclude_fields;
} else
if ($exclude_fields !== null) {
$queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields);
}
// path params
if ($campaign_id !== null) {
$resourcePath = str_replace(
'{' . 'campaign_id' . '}',
ObjectSerializer::toPathValue($campaign_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 = \GuzzleHttp\Psr7\build_query($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 = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
public function getCampaignRecipients($campaign_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0')
{
$response = $this->getCampaignRecipientsWithHttpInfo($campaign_id, $fields, $exclude_fields, $count, $offset);
return $response;
}
public function getCampaignRecipientsWithHttpInfo($campaign_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0')
{
$request = $this->getCampaignRecipientsRequest($campaign_id, $fields, $exclude_fields, $count, $offset);
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 getCampaignRecipientsRequest($campaign_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0')
{
// verify the required parameter 'campaign_id' is set
if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $campaign_id when calling '
);
}
if ($count !== null && $count > 1000) {
throw new \InvalidArgumentException('invalid value for "$count" when calling ReportsApi., must be smaller than or equal to 1000.');
}
$resourcePath = '/reports/{campaign_id}/sent-to';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if (is_array($fields)) {
$queryParams['fields'] = $fields;
} else
if ($fields !== null) {
$queryParams['fields'] = ObjectSerializer::toQueryValue($fields);
}
// query params
if (is_array($exclude_fields)) {
$queryParams['exclude_fields'] = $exclude_fields;
} else
if ($exclude_fields !== null) {
$queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields);
}
// query params
if ($count !== null) {
$queryParams['count'] = ObjectSerializer::toQueryValue($count);
}
// query params
if ($offset !== null) {
$queryParams['offset'] = ObjectSerializer::toQueryValue($offset);
}
// path params
if ($campaign_id !== null) {
$resourcePath = str_replace(
'{' . 'campaign_id' . '}',
ObjectSerializer::toPathValue($campaign_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 = \GuzzleHttp\Psr7\build_query($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 = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
public function getCampaignRecipient($campaign_id, $subscriber_hash, $fields = null, $exclude_fields = null)
{
$response = $this->getCampaignRecipientWithHttpInfo($campaign_id, $subscriber_hash, $fields, $exclude_fields);
return $response;
}
public function getCampaignRecipientWithHttpInfo($campaign_id, $subscriber_hash, $fields = null, $exclude_fields = null)
{
$request = $this->getCampaignRecipientRequest($campaign_id, $subscriber_hash, $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 getCampaignRecipientRequest($campaign_id, $subscriber_hash, $fields = null, $exclude_fields = null)
{
// verify the required parameter 'campaign_id' is set
if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $campaign_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 = '/reports/{campaign_id}/sent-to/{subscriber_hash}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if (is_array($fields)) {
$queryParams['fields'] = $fields;
} else
if ($fields !== null) {
$queryParams['fields'] = ObjectSerializer::toQueryValue($fields);
}
// query params
if (is_array($exclude_fields)) {
$queryParams['exclude_fields'] = $exclude_fields;
} else
if ($exclude_fields !== null) {
$queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields);
}
// path params
if ($campaign_id !== null) {
$resourcePath = str_replace(
'{' . 'campaign_id' . '}',
ObjectSerializer::toPathValue($campaign_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 = \GuzzleHttp\Psr7\build_query($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 = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
public function getSubReportsForCampaign($campaign_id, $fields = null, $exclude_fields = null)
{
$response = $this->getSubReportsForCampaignWithHttpInfo($campaign_id, $fields, $exclude_fields);
return $response;
}
public function getSubReportsForCampaignWithHttpInfo($campaign_id, $fields = null, $exclude_fields = null)
{
$request = $this->getSubReportsForCampaignRequest($campaign_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 getSubReportsForCampaignRequest($campaign_id, $fields = null, $exclude_fields = null)
{
// verify the required parameter 'campaign_id' is set
if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $campaign_id when calling '
);
}
$resourcePath = '/reports/{campaign_id}/sub-reports';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if (is_array($fields)) {
$queryParams['fields'] = $fields;
} else
if ($fields !== null) {
$queryParams['fields'] = ObjectSerializer::toQueryValue($fields);
}
// query params
if (is_array($exclude_fields)) {
$queryParams['exclude_fields'] = $exclude_fields;
} else
if ($exclude_fields !== null) {
$queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields);
}
// path params
if ($campaign_id !== null) {
$resourcePath = str_replace(
'{' . 'campaign_id' . '}',
ObjectSerializer::toPathValue($campaign_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 = \GuzzleHttp\Psr7\build_query($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 = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
public function getUnsubscribedListForCampaign($campaign_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0')
{
$response = $this->getUnsubscribedListForCampaignWithHttpInfo($campaign_id, $fields, $exclude_fields, $count, $offset);
return $response;
}
public function getUnsubscribedListForCampaignWithHttpInfo($campaign_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0')
{
$request = $this->getUnsubscribedListForCampaignRequest($campaign_id, $fields, $exclude_fields, $count, $offset);
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 getUnsubscribedListForCampaignRequest($campaign_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0')
{
// verify the required parameter 'campaign_id' is set
if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $campaign_id when calling '
);
}
if ($count !== null && $count > 1000) {
throw new \InvalidArgumentException('invalid value for "$count" when calling ReportsApi., must be smaller than or equal to 1000.');
}
$resourcePath = '/reports/{campaign_id}/unsubscribed';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if (is_array($fields)) {
$queryParams['fields'] = $fields;
} else
if ($fields !== null) {
$queryParams['fields'] = ObjectSerializer::toQueryValue($fields);
}
// query params
if (is_array($exclude_fields)) {
$queryParams['exclude_fields'] = $exclude_fields;
} else
if ($exclude_fields !== null) {
$queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields);
}
// query params
if ($count !== null) {
$queryParams['count'] = ObjectSerializer::toQueryValue($count);
}
// query params
if ($offset !== null) {
$queryParams['offset'] = ObjectSerializer::toQueryValue($offset);
}
// path params
if ($campaign_id !== null) {
$resourcePath = str_replace(
'{' . 'campaign_id' . '}',
ObjectSerializer::toPathValue($campaign_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 = \GuzzleHttp\Psr7\build_query($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 = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
public function getUnsubscribedListMember($campaign_id, $subscriber_hash, $fields = null, $exclude_fields = null)
{
$response = $this->getUnsubscribedListMemberWithHttpInfo($campaign_id, $subscriber_hash, $fields, $exclude_fields);
return $response;
}
public function getUnsubscribedListMemberWithHttpInfo($campaign_id, $subscriber_hash, $fields = null, $exclude_fields = null)
{
$request = $this->getUnsubscribedListMemberRequest($campaign_id, $subscriber_hash, $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 getUnsubscribedListMemberRequest($campaign_id, $subscriber_hash, $fields = null, $exclude_fields = null)
{
// verify the required parameter 'campaign_id' is set
if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $campaign_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 = '/reports/{campaign_id}/unsubscribed/{subscriber_hash}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if (is_array($fields)) {
$queryParams['fields'] = $fields;
} else
if ($fields !== null) {
$queryParams['fields'] = ObjectSerializer::toQueryValue($fields);
}
// query params
if (is_array($exclude_fields)) {
$queryParams['exclude_fields'] = $exclude_fields;
} else
if ($exclude_fields !== null) {
$queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields);
}
// path params
if ($campaign_id !== null) {
$resourcePath = str_replace(
'{' . 'campaign_id' . '}',
ObjectSerializer::toPathValue($campaign_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 = \GuzzleHttp\Psr7\build_query($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 = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$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());
}
}
return $options;
}
}