src/Sell/Marketing/V1/Api/AdApi.php
<?php
/**
* This file is part of the trollandtoad/ebay-sdk-php package.
*
* MIT License
*
* Copyright (c) 2022 Brandon Clothier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
declare(strict_types=1);
/**
* AdApi.
*
* PHP version ^7.2 || ^8.0
*
* @category Class
*
* @author OpenAPI Generator team
*
* @see https://openapi-generator.tech
*/
/**
* Marketing API.
*
* <p>The <i>Marketing API </i> offers two platforms that sellers can use to promote and advertise their products:</p> <ul><li><b>Promoted Listings</b> is an eBay ad service that lets sellers set up <i>ad campaigns </i> for the products they want to promote. eBay displays the ads in search results and in other marketing modules as <b>SPONSORED</b> listings. If an item in a Promoted Listings campaign sells, the seller is assessed a Promoted Listings fee, which is a seller-specified percentage applied to the sales price. For complete details, refer to the <a href=\"/api-docs/sell/static/marketing/pl-landing.html\">Promoted Listings playbook</a>.</li><li><b>Promotions Manager</b> gives sellers a way to offer discounts on specific items as a way to attract buyers to their inventory. Sellers can set up discounts (such as \"20% off\" and other types of offers) on specific items or on an entire customer order. To further attract buyers, eBay prominently displays promotion <i>teasers</i> throughout buyer flows. For complete details, see <a href=\"/api-docs/sell/static/marketing/promotions-manager.html\">Promotions Manager</a>.</li></ul> <p><b>Marketing reports</b>, on both the Promoted Listings and Promotions Manager platforms, give sellers information that shows the effectiveness of their marketing strategies. The data gives sellers the ability to review and fine tune their marketing efforts.</p> <p class=\"tablenote\"><b>Important!</b> Sellers must have an active eBay Store subscription, and they must accept the <b>Terms and Conditions</b> before they can make requests to these APIs in the Production environment. There are also site-specific listings requirements and restrictions associated with these marketing tools, as listed in the \"requirements and restrictions\" sections for <a href=\"/api-docs/sell/marketing/static/overview.html#PL-requirements\">Promoted Listings</a> and <a href=\"/api-docs/sell/marketing/static/overview.html#PM-requirements\">Promotions Manager</a>.</p> <p>The table below lists all the Marketing API calls grouped by resource.</p>
*
* The version of the OpenAPI document: v1.14.0
* Generated by: https://openapi-generator.tech
* OpenAPI Generator version: 5.4.0
*/
/**
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace TNT\Ebay\Sell\Marketing\V1\Api;
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\RequestOptions;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Psr7\MultipartStream;
use GuzzleHttp\Exception\GuzzleException;
use GuzzleHttp\Exception\ConnectException;
use GuzzleHttp\Exception\RequestException;
use TNT\Ebay\Sell\Marketing\V1\ApiException;
use TNT\Ebay\Sell\Marketing\V1\Configuration;
use TNT\Ebay\Sell\Marketing\V1\HeaderSelector;
use TNT\Ebay\Sell\Marketing\V1\ObjectSerializer;
/**
* AdApi Class Doc Comment.
*
* @category Class
*
* @author OpenAPI Generator team
*
* @see https://openapi-generator.tech
*/
class AdApi
{
/**
* @var ClientInterface
*/
protected $client;
/**
* @var Configuration
*/
protected $config;
/**
* @var HeaderSelector
*/
protected $headerSelector;
/**
* @var int Host index
*/
protected $hostIndex;
/**
* @param ClientInterface $client
* @param Configuration $config
* @param HeaderSelector $selector
* @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec
*/
public function __construct(
ClientInterface $client = null,
Configuration $config = null,
HeaderSelector $selector = null,
$hostIndex = 0
) {
$this->client = $client ?: new Client();
$this->config = $config ?: new Configuration();
$this->headerSelector = $selector ?: new HeaderSelector();
$this->hostIndex = $hostIndex;
}
/**
* Set the host index.
*
* @param int $hostIndex Host index (required)
*/
public function setHostIndex($hostIndex): void
{
$this->hostIndex = $hostIndex;
}
/**
* Get the host index.
*
* @return int Host index
*/
public function getHostIndex()
{
return $this->hostIndex;
}
/**
* @return Configuration
*/
public function getConfiguration()
{
return $this->config;
}
/**
* Operation bulkCreateAdsByInventoryReference.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created. Get a seller's campaign IDs by calling <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a>. (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\BulkCreateAdsByInventoryReferenceRequest $bulk_create_ads_by_inventory_reference_request The container for the bulk request to create ads for eBay inventory reference IDs. eBay inventory reference IDs are seller-defined IDs used by theInventory API. (required)
*
* @throws \TNT\Ebay\Sell\Marketing\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return \TNT\Ebay\Sell\Marketing\V1\Model\BulkCreateAdsByInventoryReferenceResponse
*/
public function bulkCreateAdsByInventoryReference($campaign_id, $bulk_create_ads_by_inventory_reference_request)
{
[$response] = $this->bulkCreateAdsByInventoryReferenceWithHttpInfo($campaign_id, $bulk_create_ads_by_inventory_reference_request);
return $response;
}
/**
* Operation bulkCreateAdsByInventoryReferenceWithHttpInfo.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created. Get a seller's campaign IDs by calling <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a>. (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\BulkCreateAdsByInventoryReferenceRequest $bulk_create_ads_by_inventory_reference_request The container for the bulk request to create ads for eBay inventory reference IDs. eBay inventory reference IDs are seller-defined IDs used by theInventory API. (required)
*
* @throws \TNT\Ebay\Sell\Marketing\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return array of \TNT\Ebay\Sell\Marketing\V1\Model\BulkCreateAdsByInventoryReferenceResponse, HTTP status code, HTTP response headers (array of strings)
*/
public function bulkCreateAdsByInventoryReferenceWithHttpInfo($campaign_id, $bulk_create_ads_by_inventory_reference_request)
{
$request = $this->bulkCreateAdsByInventoryReferenceRequest($campaign_id, $bulk_create_ads_by_inventory_reference_request);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null, $e);
} catch (ConnectException $e) {
throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), null, null, $e);
} catch (GuzzleException $e) {
throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), null, null, $e);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(sprintf('[%d] Error connecting to the API (%s)', $statusCode, (string) $request->getUri()), $statusCode, $response->getHeaders(), (string) $response->getBody());
}
switch ($statusCode) {
case 200:
if ('\TNT\Ebay\Sell\Marketing\V1\Model\BulkCreateAdsByInventoryReferenceResponse' === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, '\TNT\Ebay\Sell\Marketing\V1\Model\BulkCreateAdsByInventoryReferenceResponse', []),
$response->getStatusCode(),
$response->getHeaders(),
];
}
$returnType = '\TNT\Ebay\Sell\Marketing\V1\Model\BulkCreateAdsByInventoryReferenceResponse';
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders(),
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'\TNT\Ebay\Sell\Marketing\V1\Model\BulkCreateAdsByInventoryReferenceResponse',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation bulkCreateAdsByInventoryReferenceAsync.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created. Get a seller's campaign IDs by calling <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a>. (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\BulkCreateAdsByInventoryReferenceRequest $bulk_create_ads_by_inventory_reference_request The container for the bulk request to create ads for eBay inventory reference IDs. eBay inventory reference IDs are seller-defined IDs used by theInventory API. (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function bulkCreateAdsByInventoryReferenceAsync($campaign_id, $bulk_create_ads_by_inventory_reference_request)
{
return $this->bulkCreateAdsByInventoryReferenceAsyncWithHttpInfo($campaign_id, $bulk_create_ads_by_inventory_reference_request)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation bulkCreateAdsByInventoryReferenceAsyncWithHttpInfo.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created. Get a seller's campaign IDs by calling <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a>. (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\BulkCreateAdsByInventoryReferenceRequest $bulk_create_ads_by_inventory_reference_request The container for the bulk request to create ads for eBay inventory reference IDs. eBay inventory reference IDs are seller-defined IDs used by theInventory API. (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function bulkCreateAdsByInventoryReferenceAsyncWithHttpInfo($campaign_id, $bulk_create_ads_by_inventory_reference_request)
{
$returnType = '\TNT\Ebay\Sell\Marketing\V1\Model\BulkCreateAdsByInventoryReferenceResponse';
$request = $this->bulkCreateAdsByInventoryReferenceRequest($campaign_id, $bulk_create_ads_by_inventory_reference_request);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders(),
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(sprintf('[%d] Error connecting to the API (%s)', $statusCode, $exception->getRequest()->getUri()), $statusCode, $response->getHeaders(), (string) $response->getBody(), $exception instanceof \Throwable ? $exception : null);
}
);
}
/**
* Create request for operation 'bulkCreateAdsByInventoryReference'.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created. Get a seller's campaign IDs by calling <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a>. (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\BulkCreateAdsByInventoryReferenceRequest $bulk_create_ads_by_inventory_reference_request The container for the bulk request to create ads for eBay inventory reference IDs. eBay inventory reference IDs are seller-defined IDs used by theInventory API. (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Psr7\Request
*/
public function bulkCreateAdsByInventoryReferenceRequest($campaign_id, $bulk_create_ads_by_inventory_reference_request)
{
// 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 bulkCreateAdsByInventoryReference');
}
// Verify the required parameter 'bulk_create_ads_by_inventory_reference_request' is set.
if ($bulk_create_ads_by_inventory_reference_request === null || (\is_array($bulk_create_ads_by_inventory_reference_request) && count($bulk_create_ads_by_inventory_reference_request) === 0)) {
throw new \InvalidArgumentException('Missing the required parameter $bulk_create_ads_by_inventory_reference_request when calling bulkCreateAdsByInventoryReference');
}
$resourcePath = '/ad_campaign/{campaign_id}/bulk_create_ads_by_inventory_reference';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// path params
if ($campaign_id !== null) {
$resourcePath = str_replace(
'{campaign_id}',
ObjectSerializer::toPathValue($campaign_id),
$resourcePath
);
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// For model (json/xml)
if (isset($bulk_create_ads_by_inventory_reference_request)) {
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($bulk_create_ads_by_inventory_reference_request));
} else {
$httpBody = $bulk_create_ads_by_inventory_reference_request;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
foreach ($formParamValueItems as $formParamValueItem) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValueItem,
];
}
}
// For HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// For HTTP post (form)
$httpBody = ObjectSerializer::buildQuery($queryParams);
}
}
// this endpoint requires OAuth (access token)
if (! empty($this->config->getAccessToken())) {
$headers['Authorization'] = 'Bearer '.$this->config->getAccessToken();
}
// this endpoint requires OAuth (access token)
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 = ObjectSerializer::buildQuery($queryParams);
return new Request(
'POST',
$this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation bulkCreateAdsByListingId.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that's generated when a campaign is created. Get a seller's campaign IDs by calling <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a>. (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\BulkCreateAdRequest $bulk_create_ad_request The container for the bulk request to create ads for eBay listing IDs. eBay listing IDs are generated by the Trading API and Inventory API when the listing is created on eBay. (required)
*
* @throws \TNT\Ebay\Sell\Marketing\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return \TNT\Ebay\Sell\Marketing\V1\Model\BulkAdResponse
*/
public function bulkCreateAdsByListingId($campaign_id, $bulk_create_ad_request)
{
[$response] = $this->bulkCreateAdsByListingIdWithHttpInfo($campaign_id, $bulk_create_ad_request);
return $response;
}
/**
* Operation bulkCreateAdsByListingIdWithHttpInfo.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that's generated when a campaign is created. Get a seller's campaign IDs by calling <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a>. (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\BulkCreateAdRequest $bulk_create_ad_request The container for the bulk request to create ads for eBay listing IDs. eBay listing IDs are generated by the Trading API and Inventory API when the listing is created on eBay. (required)
*
* @throws \TNT\Ebay\Sell\Marketing\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return array of \TNT\Ebay\Sell\Marketing\V1\Model\BulkAdResponse, HTTP status code, HTTP response headers (array of strings)
*/
public function bulkCreateAdsByListingIdWithHttpInfo($campaign_id, $bulk_create_ad_request)
{
$request = $this->bulkCreateAdsByListingIdRequest($campaign_id, $bulk_create_ad_request);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null, $e);
} catch (ConnectException $e) {
throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), null, null, $e);
} catch (GuzzleException $e) {
throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), null, null, $e);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(sprintf('[%d] Error connecting to the API (%s)', $statusCode, (string) $request->getUri()), $statusCode, $response->getHeaders(), (string) $response->getBody());
}
switch ($statusCode) {
case 200:
if ('\TNT\Ebay\Sell\Marketing\V1\Model\BulkAdResponse' === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, '\TNT\Ebay\Sell\Marketing\V1\Model\BulkAdResponse', []),
$response->getStatusCode(),
$response->getHeaders(),
];
}
$returnType = '\TNT\Ebay\Sell\Marketing\V1\Model\BulkAdResponse';
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders(),
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'\TNT\Ebay\Sell\Marketing\V1\Model\BulkAdResponse',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation bulkCreateAdsByListingIdAsync.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that's generated when a campaign is created. Get a seller's campaign IDs by calling <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a>. (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\BulkCreateAdRequest $bulk_create_ad_request The container for the bulk request to create ads for eBay listing IDs. eBay listing IDs are generated by the Trading API and Inventory API when the listing is created on eBay. (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function bulkCreateAdsByListingIdAsync($campaign_id, $bulk_create_ad_request)
{
return $this->bulkCreateAdsByListingIdAsyncWithHttpInfo($campaign_id, $bulk_create_ad_request)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation bulkCreateAdsByListingIdAsyncWithHttpInfo.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that's generated when a campaign is created. Get a seller's campaign IDs by calling <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a>. (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\BulkCreateAdRequest $bulk_create_ad_request The container for the bulk request to create ads for eBay listing IDs. eBay listing IDs are generated by the Trading API and Inventory API when the listing is created on eBay. (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function bulkCreateAdsByListingIdAsyncWithHttpInfo($campaign_id, $bulk_create_ad_request)
{
$returnType = '\TNT\Ebay\Sell\Marketing\V1\Model\BulkAdResponse';
$request = $this->bulkCreateAdsByListingIdRequest($campaign_id, $bulk_create_ad_request);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders(),
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(sprintf('[%d] Error connecting to the API (%s)', $statusCode, $exception->getRequest()->getUri()), $statusCode, $response->getHeaders(), (string) $response->getBody(), $exception instanceof \Throwable ? $exception : null);
}
);
}
/**
* Create request for operation 'bulkCreateAdsByListingId'.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that's generated when a campaign is created. Get a seller's campaign IDs by calling <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a>. (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\BulkCreateAdRequest $bulk_create_ad_request The container for the bulk request to create ads for eBay listing IDs. eBay listing IDs are generated by the Trading API and Inventory API when the listing is created on eBay. (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Psr7\Request
*/
public function bulkCreateAdsByListingIdRequest($campaign_id, $bulk_create_ad_request)
{
// 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 bulkCreateAdsByListingId');
}
// Verify the required parameter 'bulk_create_ad_request' is set.
if ($bulk_create_ad_request === null || (\is_array($bulk_create_ad_request) && count($bulk_create_ad_request) === 0)) {
throw new \InvalidArgumentException('Missing the required parameter $bulk_create_ad_request when calling bulkCreateAdsByListingId');
}
$resourcePath = '/ad_campaign/{campaign_id}/bulk_create_ads_by_listing_id';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// path params
if ($campaign_id !== null) {
$resourcePath = str_replace(
'{campaign_id}',
ObjectSerializer::toPathValue($campaign_id),
$resourcePath
);
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// For model (json/xml)
if (isset($bulk_create_ad_request)) {
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($bulk_create_ad_request));
} else {
$httpBody = $bulk_create_ad_request;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
foreach ($formParamValueItems as $formParamValueItem) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValueItem,
];
}
}
// For HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// For HTTP post (form)
$httpBody = ObjectSerializer::buildQuery($queryParams);
}
}
// this endpoint requires OAuth (access token)
if (! empty($this->config->getAccessToken())) {
$headers['Authorization'] = 'Bearer '.$this->config->getAccessToken();
}
// this endpoint requires OAuth (access token)
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 = ObjectSerializer::buildQuery($queryParams);
return new Request(
'POST',
$this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation bulkDeleteAdsByInventoryReference.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that's generated when a campaign is created. Get a seller's campaign IDs by calling <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a>. (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\BulkDeleteAdsByInventoryReferenceRequest $bulk_delete_ads_by_inventory_reference_request This request works with listings created via the <a href=\"/api-docs/sell/inventory/resources/methods\">Inventory API</a>.<br /><br />The request is to delete a set of ads in bulk, as specified by a list of inventory reference IDs from the specified campaign. (required)
*
* @throws \TNT\Ebay\Sell\Marketing\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return \TNT\Ebay\Sell\Marketing\V1\Model\BulkDeleteAdsByInventoryReferenceResponse
*/
public function bulkDeleteAdsByInventoryReference($campaign_id, $bulk_delete_ads_by_inventory_reference_request)
{
[$response] = $this->bulkDeleteAdsByInventoryReferenceWithHttpInfo($campaign_id, $bulk_delete_ads_by_inventory_reference_request);
return $response;
}
/**
* Operation bulkDeleteAdsByInventoryReferenceWithHttpInfo.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that's generated when a campaign is created. Get a seller's campaign IDs by calling <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a>. (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\BulkDeleteAdsByInventoryReferenceRequest $bulk_delete_ads_by_inventory_reference_request This request works with listings created via the <a href=\"/api-docs/sell/inventory/resources/methods\">Inventory API</a>.<br /><br />The request is to delete a set of ads in bulk, as specified by a list of inventory reference IDs from the specified campaign. (required)
*
* @throws \TNT\Ebay\Sell\Marketing\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return array of \TNT\Ebay\Sell\Marketing\V1\Model\BulkDeleteAdsByInventoryReferenceResponse, HTTP status code, HTTP response headers (array of strings)
*/
public function bulkDeleteAdsByInventoryReferenceWithHttpInfo($campaign_id, $bulk_delete_ads_by_inventory_reference_request)
{
$request = $this->bulkDeleteAdsByInventoryReferenceRequest($campaign_id, $bulk_delete_ads_by_inventory_reference_request);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null, $e);
} catch (ConnectException $e) {
throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), null, null, $e);
} catch (GuzzleException $e) {
throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), null, null, $e);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(sprintf('[%d] Error connecting to the API (%s)', $statusCode, (string) $request->getUri()), $statusCode, $response->getHeaders(), (string) $response->getBody());
}
switch ($statusCode) {
case 200:
if ('\TNT\Ebay\Sell\Marketing\V1\Model\BulkDeleteAdsByInventoryReferenceResponse' === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, '\TNT\Ebay\Sell\Marketing\V1\Model\BulkDeleteAdsByInventoryReferenceResponse', []),
$response->getStatusCode(),
$response->getHeaders(),
];
}
$returnType = '\TNT\Ebay\Sell\Marketing\V1\Model\BulkDeleteAdsByInventoryReferenceResponse';
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders(),
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'\TNT\Ebay\Sell\Marketing\V1\Model\BulkDeleteAdsByInventoryReferenceResponse',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation bulkDeleteAdsByInventoryReferenceAsync.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that's generated when a campaign is created. Get a seller's campaign IDs by calling <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a>. (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\BulkDeleteAdsByInventoryReferenceRequest $bulk_delete_ads_by_inventory_reference_request This request works with listings created via the <a href=\"/api-docs/sell/inventory/resources/methods\">Inventory API</a>.<br /><br />The request is to delete a set of ads in bulk, as specified by a list of inventory reference IDs from the specified campaign. (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function bulkDeleteAdsByInventoryReferenceAsync($campaign_id, $bulk_delete_ads_by_inventory_reference_request)
{
return $this->bulkDeleteAdsByInventoryReferenceAsyncWithHttpInfo($campaign_id, $bulk_delete_ads_by_inventory_reference_request)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation bulkDeleteAdsByInventoryReferenceAsyncWithHttpInfo.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that's generated when a campaign is created. Get a seller's campaign IDs by calling <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a>. (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\BulkDeleteAdsByInventoryReferenceRequest $bulk_delete_ads_by_inventory_reference_request This request works with listings created via the <a href=\"/api-docs/sell/inventory/resources/methods\">Inventory API</a>.<br /><br />The request is to delete a set of ads in bulk, as specified by a list of inventory reference IDs from the specified campaign. (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function bulkDeleteAdsByInventoryReferenceAsyncWithHttpInfo($campaign_id, $bulk_delete_ads_by_inventory_reference_request)
{
$returnType = '\TNT\Ebay\Sell\Marketing\V1\Model\BulkDeleteAdsByInventoryReferenceResponse';
$request = $this->bulkDeleteAdsByInventoryReferenceRequest($campaign_id, $bulk_delete_ads_by_inventory_reference_request);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders(),
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(sprintf('[%d] Error connecting to the API (%s)', $statusCode, $exception->getRequest()->getUri()), $statusCode, $response->getHeaders(), (string) $response->getBody(), $exception instanceof \Throwable ? $exception : null);
}
);
}
/**
* Create request for operation 'bulkDeleteAdsByInventoryReference'.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that's generated when a campaign is created. Get a seller's campaign IDs by calling <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a>. (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\BulkDeleteAdsByInventoryReferenceRequest $bulk_delete_ads_by_inventory_reference_request This request works with listings created via the <a href=\"/api-docs/sell/inventory/resources/methods\">Inventory API</a>.<br /><br />The request is to delete a set of ads in bulk, as specified by a list of inventory reference IDs from the specified campaign. (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Psr7\Request
*/
public function bulkDeleteAdsByInventoryReferenceRequest($campaign_id, $bulk_delete_ads_by_inventory_reference_request)
{
// 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 bulkDeleteAdsByInventoryReference');
}
// Verify the required parameter 'bulk_delete_ads_by_inventory_reference_request' is set.
if ($bulk_delete_ads_by_inventory_reference_request === null || (\is_array($bulk_delete_ads_by_inventory_reference_request) && count($bulk_delete_ads_by_inventory_reference_request) === 0)) {
throw new \InvalidArgumentException('Missing the required parameter $bulk_delete_ads_by_inventory_reference_request when calling bulkDeleteAdsByInventoryReference');
}
$resourcePath = '/ad_campaign/{campaign_id}/bulk_delete_ads_by_inventory_reference';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// path params
if ($campaign_id !== null) {
$resourcePath = str_replace(
'{campaign_id}',
ObjectSerializer::toPathValue($campaign_id),
$resourcePath
);
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// For model (json/xml)
if (isset($bulk_delete_ads_by_inventory_reference_request)) {
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($bulk_delete_ads_by_inventory_reference_request));
} else {
$httpBody = $bulk_delete_ads_by_inventory_reference_request;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
foreach ($formParamValueItems as $formParamValueItem) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValueItem,
];
}
}
// For HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// For HTTP post (form)
$httpBody = ObjectSerializer::buildQuery($queryParams);
}
}
// this endpoint requires OAuth (access token)
if (! empty($this->config->getAccessToken())) {
$headers['Authorization'] = 'Bearer '.$this->config->getAccessToken();
}
// this endpoint requires OAuth (access token)
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 = ObjectSerializer::buildQuery($queryParams);
return new Request(
'POST',
$this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation bulkDeleteAdsByListingId.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that's generated when a campaign is created. Get a seller's campaign IDs by calling <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a>. (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\BulkDeleteAdRequest $bulk_delete_ad_request This request object defines the fields for the <b>bulkDeleteAdsByListingId</b> request. (required)
*
* @throws \TNT\Ebay\Sell\Marketing\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return \TNT\Ebay\Sell\Marketing\V1\Model\BulkDeleteAdResponse
*/
public function bulkDeleteAdsByListingId($campaign_id, $bulk_delete_ad_request)
{
[$response] = $this->bulkDeleteAdsByListingIdWithHttpInfo($campaign_id, $bulk_delete_ad_request);
return $response;
}
/**
* Operation bulkDeleteAdsByListingIdWithHttpInfo.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that's generated when a campaign is created. Get a seller's campaign IDs by calling <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a>. (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\BulkDeleteAdRequest $bulk_delete_ad_request This request object defines the fields for the <b>bulkDeleteAdsByListingId</b> request. (required)
*
* @throws \TNT\Ebay\Sell\Marketing\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return array of \TNT\Ebay\Sell\Marketing\V1\Model\BulkDeleteAdResponse, HTTP status code, HTTP response headers (array of strings)
*/
public function bulkDeleteAdsByListingIdWithHttpInfo($campaign_id, $bulk_delete_ad_request)
{
$request = $this->bulkDeleteAdsByListingIdRequest($campaign_id, $bulk_delete_ad_request);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null, $e);
} catch (ConnectException $e) {
throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), null, null, $e);
} catch (GuzzleException $e) {
throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), null, null, $e);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(sprintf('[%d] Error connecting to the API (%s)', $statusCode, (string) $request->getUri()), $statusCode, $response->getHeaders(), (string) $response->getBody());
}
switch ($statusCode) {
case 200:
if ('\TNT\Ebay\Sell\Marketing\V1\Model\BulkDeleteAdResponse' === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, '\TNT\Ebay\Sell\Marketing\V1\Model\BulkDeleteAdResponse', []),
$response->getStatusCode(),
$response->getHeaders(),
];
}
$returnType = '\TNT\Ebay\Sell\Marketing\V1\Model\BulkDeleteAdResponse';
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders(),
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'\TNT\Ebay\Sell\Marketing\V1\Model\BulkDeleteAdResponse',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation bulkDeleteAdsByListingIdAsync.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that's generated when a campaign is created. Get a seller's campaign IDs by calling <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a>. (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\BulkDeleteAdRequest $bulk_delete_ad_request This request object defines the fields for the <b>bulkDeleteAdsByListingId</b> request. (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function bulkDeleteAdsByListingIdAsync($campaign_id, $bulk_delete_ad_request)
{
return $this->bulkDeleteAdsByListingIdAsyncWithHttpInfo($campaign_id, $bulk_delete_ad_request)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation bulkDeleteAdsByListingIdAsyncWithHttpInfo.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that's generated when a campaign is created. Get a seller's campaign IDs by calling <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a>. (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\BulkDeleteAdRequest $bulk_delete_ad_request This request object defines the fields for the <b>bulkDeleteAdsByListingId</b> request. (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function bulkDeleteAdsByListingIdAsyncWithHttpInfo($campaign_id, $bulk_delete_ad_request)
{
$returnType = '\TNT\Ebay\Sell\Marketing\V1\Model\BulkDeleteAdResponse';
$request = $this->bulkDeleteAdsByListingIdRequest($campaign_id, $bulk_delete_ad_request);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders(),
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(sprintf('[%d] Error connecting to the API (%s)', $statusCode, $exception->getRequest()->getUri()), $statusCode, $response->getHeaders(), (string) $response->getBody(), $exception instanceof \Throwable ? $exception : null);
}
);
}
/**
* Create request for operation 'bulkDeleteAdsByListingId'.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that's generated when a campaign is created. Get a seller's campaign IDs by calling <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a>. (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\BulkDeleteAdRequest $bulk_delete_ad_request This request object defines the fields for the <b>bulkDeleteAdsByListingId</b> request. (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Psr7\Request
*/
public function bulkDeleteAdsByListingIdRequest($campaign_id, $bulk_delete_ad_request)
{
// 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 bulkDeleteAdsByListingId');
}
// Verify the required parameter 'bulk_delete_ad_request' is set.
if ($bulk_delete_ad_request === null || (\is_array($bulk_delete_ad_request) && count($bulk_delete_ad_request) === 0)) {
throw new \InvalidArgumentException('Missing the required parameter $bulk_delete_ad_request when calling bulkDeleteAdsByListingId');
}
$resourcePath = '/ad_campaign/{campaign_id}/bulk_delete_ads_by_listing_id';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// path params
if ($campaign_id !== null) {
$resourcePath = str_replace(
'{campaign_id}',
ObjectSerializer::toPathValue($campaign_id),
$resourcePath
);
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// For model (json/xml)
if (isset($bulk_delete_ad_request)) {
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($bulk_delete_ad_request));
} else {
$httpBody = $bulk_delete_ad_request;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
foreach ($formParamValueItems as $formParamValueItem) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValueItem,
];
}
}
// For HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// For HTTP post (form)
$httpBody = ObjectSerializer::buildQuery($queryParams);
}
}
// this endpoint requires OAuth (access token)
if (! empty($this->config->getAccessToken())) {
$headers['Authorization'] = 'Bearer '.$this->config->getAccessToken();
}
// this endpoint requires OAuth (access token)
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 = ObjectSerializer::buildQuery($queryParams);
return new Request(
'POST',
$this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation bulkUpdateAdsBidByInventoryReference.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that's generated when a campaign is created. Get a seller's campaign IDs by calling <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a>. (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\BulkCreateAdsByInventoryReferenceRequest $bulk_create_ads_by_inventory_reference_request This request object defines the fields for the <b>BulkCreateAdsByInventoryReference</b> request. (required)
*
* @throws \TNT\Ebay\Sell\Marketing\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return \TNT\Ebay\Sell\Marketing\V1\Model\BulkUpdateAdsByInventoryReferenceResponse
*/
public function bulkUpdateAdsBidByInventoryReference($campaign_id, $bulk_create_ads_by_inventory_reference_request)
{
[$response] = $this->bulkUpdateAdsBidByInventoryReferenceWithHttpInfo($campaign_id, $bulk_create_ads_by_inventory_reference_request);
return $response;
}
/**
* Operation bulkUpdateAdsBidByInventoryReferenceWithHttpInfo.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that's generated when a campaign is created. Get a seller's campaign IDs by calling <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a>. (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\BulkCreateAdsByInventoryReferenceRequest $bulk_create_ads_by_inventory_reference_request This request object defines the fields for the <b>BulkCreateAdsByInventoryReference</b> request. (required)
*
* @throws \TNT\Ebay\Sell\Marketing\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return array of \TNT\Ebay\Sell\Marketing\V1\Model\BulkUpdateAdsByInventoryReferenceResponse, HTTP status code, HTTP response headers (array of strings)
*/
public function bulkUpdateAdsBidByInventoryReferenceWithHttpInfo($campaign_id, $bulk_create_ads_by_inventory_reference_request)
{
$request = $this->bulkUpdateAdsBidByInventoryReferenceRequest($campaign_id, $bulk_create_ads_by_inventory_reference_request);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null, $e);
} catch (ConnectException $e) {
throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), null, null, $e);
} catch (GuzzleException $e) {
throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), null, null, $e);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(sprintf('[%d] Error connecting to the API (%s)', $statusCode, (string) $request->getUri()), $statusCode, $response->getHeaders(), (string) $response->getBody());
}
switch ($statusCode) {
case 200:
if ('\TNT\Ebay\Sell\Marketing\V1\Model\BulkUpdateAdsByInventoryReferenceResponse' === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, '\TNT\Ebay\Sell\Marketing\V1\Model\BulkUpdateAdsByInventoryReferenceResponse', []),
$response->getStatusCode(),
$response->getHeaders(),
];
}
$returnType = '\TNT\Ebay\Sell\Marketing\V1\Model\BulkUpdateAdsByInventoryReferenceResponse';
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders(),
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'\TNT\Ebay\Sell\Marketing\V1\Model\BulkUpdateAdsByInventoryReferenceResponse',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation bulkUpdateAdsBidByInventoryReferenceAsync.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that's generated when a campaign is created. Get a seller's campaign IDs by calling <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a>. (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\BulkCreateAdsByInventoryReferenceRequest $bulk_create_ads_by_inventory_reference_request This request object defines the fields for the <b>BulkCreateAdsByInventoryReference</b> request. (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function bulkUpdateAdsBidByInventoryReferenceAsync($campaign_id, $bulk_create_ads_by_inventory_reference_request)
{
return $this->bulkUpdateAdsBidByInventoryReferenceAsyncWithHttpInfo($campaign_id, $bulk_create_ads_by_inventory_reference_request)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation bulkUpdateAdsBidByInventoryReferenceAsyncWithHttpInfo.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that's generated when a campaign is created. Get a seller's campaign IDs by calling <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a>. (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\BulkCreateAdsByInventoryReferenceRequest $bulk_create_ads_by_inventory_reference_request This request object defines the fields for the <b>BulkCreateAdsByInventoryReference</b> request. (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function bulkUpdateAdsBidByInventoryReferenceAsyncWithHttpInfo($campaign_id, $bulk_create_ads_by_inventory_reference_request)
{
$returnType = '\TNT\Ebay\Sell\Marketing\V1\Model\BulkUpdateAdsByInventoryReferenceResponse';
$request = $this->bulkUpdateAdsBidByInventoryReferenceRequest($campaign_id, $bulk_create_ads_by_inventory_reference_request);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders(),
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(sprintf('[%d] Error connecting to the API (%s)', $statusCode, $exception->getRequest()->getUri()), $statusCode, $response->getHeaders(), (string) $response->getBody(), $exception instanceof \Throwable ? $exception : null);
}
);
}
/**
* Create request for operation 'bulkUpdateAdsBidByInventoryReference'.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that's generated when a campaign is created. Get a seller's campaign IDs by calling <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a>. (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\BulkCreateAdsByInventoryReferenceRequest $bulk_create_ads_by_inventory_reference_request This request object defines the fields for the <b>BulkCreateAdsByInventoryReference</b> request. (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Psr7\Request
*/
public function bulkUpdateAdsBidByInventoryReferenceRequest($campaign_id, $bulk_create_ads_by_inventory_reference_request)
{
// 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 bulkUpdateAdsBidByInventoryReference');
}
// Verify the required parameter 'bulk_create_ads_by_inventory_reference_request' is set.
if ($bulk_create_ads_by_inventory_reference_request === null || (\is_array($bulk_create_ads_by_inventory_reference_request) && count($bulk_create_ads_by_inventory_reference_request) === 0)) {
throw new \InvalidArgumentException('Missing the required parameter $bulk_create_ads_by_inventory_reference_request when calling bulkUpdateAdsBidByInventoryReference');
}
$resourcePath = '/ad_campaign/{campaign_id}/bulk_update_ads_bid_by_inventory_reference';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// path params
if ($campaign_id !== null) {
$resourcePath = str_replace(
'{campaign_id}',
ObjectSerializer::toPathValue($campaign_id),
$resourcePath
);
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// For model (json/xml)
if (isset($bulk_create_ads_by_inventory_reference_request)) {
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($bulk_create_ads_by_inventory_reference_request));
} else {
$httpBody = $bulk_create_ads_by_inventory_reference_request;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
foreach ($formParamValueItems as $formParamValueItem) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValueItem,
];
}
}
// For HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// For HTTP post (form)
$httpBody = ObjectSerializer::buildQuery($queryParams);
}
}
// this endpoint requires OAuth (access token)
if (! empty($this->config->getAccessToken())) {
$headers['Authorization'] = 'Bearer '.$this->config->getAccessToken();
}
// this endpoint requires OAuth (access token)
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 = ObjectSerializer::buildQuery($queryParams);
return new Request(
'POST',
$this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation bulkUpdateAdsBidByListingId.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that's generated when a campaign is created. Get a seller's campaign IDs by calling <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a>. (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\BulkCreateAdRequest $bulk_create_ad_request This request object defines the fields for the <b>BulkCreateAdsByListingId</b> request. (required)
*
* @throws \TNT\Ebay\Sell\Marketing\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return \TNT\Ebay\Sell\Marketing\V1\Model\BulkAdUpdateResponse
*/
public function bulkUpdateAdsBidByListingId($campaign_id, $bulk_create_ad_request)
{
[$response] = $this->bulkUpdateAdsBidByListingIdWithHttpInfo($campaign_id, $bulk_create_ad_request);
return $response;
}
/**
* Operation bulkUpdateAdsBidByListingIdWithHttpInfo.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that's generated when a campaign is created. Get a seller's campaign IDs by calling <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a>. (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\BulkCreateAdRequest $bulk_create_ad_request This request object defines the fields for the <b>BulkCreateAdsByListingId</b> request. (required)
*
* @throws \TNT\Ebay\Sell\Marketing\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return array of \TNT\Ebay\Sell\Marketing\V1\Model\BulkAdUpdateResponse, HTTP status code, HTTP response headers (array of strings)
*/
public function bulkUpdateAdsBidByListingIdWithHttpInfo($campaign_id, $bulk_create_ad_request)
{
$request = $this->bulkUpdateAdsBidByListingIdRequest($campaign_id, $bulk_create_ad_request);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null, $e);
} catch (ConnectException $e) {
throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), null, null, $e);
} catch (GuzzleException $e) {
throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), null, null, $e);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(sprintf('[%d] Error connecting to the API (%s)', $statusCode, (string) $request->getUri()), $statusCode, $response->getHeaders(), (string) $response->getBody());
}
switch ($statusCode) {
case 200:
if ('\TNT\Ebay\Sell\Marketing\V1\Model\BulkAdUpdateResponse' === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, '\TNT\Ebay\Sell\Marketing\V1\Model\BulkAdUpdateResponse', []),
$response->getStatusCode(),
$response->getHeaders(),
];
}
$returnType = '\TNT\Ebay\Sell\Marketing\V1\Model\BulkAdUpdateResponse';
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders(),
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'\TNT\Ebay\Sell\Marketing\V1\Model\BulkAdUpdateResponse',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation bulkUpdateAdsBidByListingIdAsync.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that's generated when a campaign is created. Get a seller's campaign IDs by calling <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a>. (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\BulkCreateAdRequest $bulk_create_ad_request This request object defines the fields for the <b>BulkCreateAdsByListingId</b> request. (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function bulkUpdateAdsBidByListingIdAsync($campaign_id, $bulk_create_ad_request)
{
return $this->bulkUpdateAdsBidByListingIdAsyncWithHttpInfo($campaign_id, $bulk_create_ad_request)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation bulkUpdateAdsBidByListingIdAsyncWithHttpInfo.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that's generated when a campaign is created. Get a seller's campaign IDs by calling <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a>. (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\BulkCreateAdRequest $bulk_create_ad_request This request object defines the fields for the <b>BulkCreateAdsByListingId</b> request. (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function bulkUpdateAdsBidByListingIdAsyncWithHttpInfo($campaign_id, $bulk_create_ad_request)
{
$returnType = '\TNT\Ebay\Sell\Marketing\V1\Model\BulkAdUpdateResponse';
$request = $this->bulkUpdateAdsBidByListingIdRequest($campaign_id, $bulk_create_ad_request);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders(),
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(sprintf('[%d] Error connecting to the API (%s)', $statusCode, $exception->getRequest()->getUri()), $statusCode, $response->getHeaders(), (string) $response->getBody(), $exception instanceof \Throwable ? $exception : null);
}
);
}
/**
* Create request for operation 'bulkUpdateAdsBidByListingId'.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that's generated when a campaign is created. Get a seller's campaign IDs by calling <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a>. (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\BulkCreateAdRequest $bulk_create_ad_request This request object defines the fields for the <b>BulkCreateAdsByListingId</b> request. (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Psr7\Request
*/
public function bulkUpdateAdsBidByListingIdRequest($campaign_id, $bulk_create_ad_request)
{
// 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 bulkUpdateAdsBidByListingId');
}
// Verify the required parameter 'bulk_create_ad_request' is set.
if ($bulk_create_ad_request === null || (\is_array($bulk_create_ad_request) && count($bulk_create_ad_request) === 0)) {
throw new \InvalidArgumentException('Missing the required parameter $bulk_create_ad_request when calling bulkUpdateAdsBidByListingId');
}
$resourcePath = '/ad_campaign/{campaign_id}/bulk_update_ads_bid_by_listing_id';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// path params
if ($campaign_id !== null) {
$resourcePath = str_replace(
'{campaign_id}',
ObjectSerializer::toPathValue($campaign_id),
$resourcePath
);
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// For model (json/xml)
if (isset($bulk_create_ad_request)) {
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($bulk_create_ad_request));
} else {
$httpBody = $bulk_create_ad_request;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
foreach ($formParamValueItems as $formParamValueItem) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValueItem,
];
}
}
// For HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// For HTTP post (form)
$httpBody = ObjectSerializer::buildQuery($queryParams);
}
}
// this endpoint requires OAuth (access token)
if (! empty($this->config->getAccessToken())) {
$headers['Authorization'] = 'Bearer '.$this->config->getAccessToken();
}
// this endpoint requires OAuth (access token)
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 = ObjectSerializer::buildQuery($queryParams);
return new Request(
'POST',
$this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation bulkUpdateAdsStatus.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created.<br /><br /><span class=\"tablenote\"><b>Note:</b> You can retrieve the campaign IDs for a specified seller using the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a> method.</span> (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\BulkUpdateAdStatusRequest $bulk_update_ad_status_request The bulk request to update the ads. (required)
*
* @throws \TNT\Ebay\Sell\Marketing\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return \TNT\Ebay\Sell\Marketing\V1\Model\BulkAdUpdateStatusResponse
*/
public function bulkUpdateAdsStatus($campaign_id, $bulk_update_ad_status_request)
{
[$response] = $this->bulkUpdateAdsStatusWithHttpInfo($campaign_id, $bulk_update_ad_status_request);
return $response;
}
/**
* Operation bulkUpdateAdsStatusWithHttpInfo.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created.<br /><br /><span class=\"tablenote\"><b>Note:</b> You can retrieve the campaign IDs for a specified seller using the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a> method.</span> (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\BulkUpdateAdStatusRequest $bulk_update_ad_status_request The bulk request to update the ads. (required)
*
* @throws \TNT\Ebay\Sell\Marketing\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return array of \TNT\Ebay\Sell\Marketing\V1\Model\BulkAdUpdateStatusResponse, HTTP status code, HTTP response headers (array of strings)
*/
public function bulkUpdateAdsStatusWithHttpInfo($campaign_id, $bulk_update_ad_status_request)
{
$request = $this->bulkUpdateAdsStatusRequest($campaign_id, $bulk_update_ad_status_request);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null, $e);
} catch (ConnectException $e) {
throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), null, null, $e);
} catch (GuzzleException $e) {
throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), null, null, $e);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(sprintf('[%d] Error connecting to the API (%s)', $statusCode, (string) $request->getUri()), $statusCode, $response->getHeaders(), (string) $response->getBody());
}
switch ($statusCode) {
case 200:
if ('\TNT\Ebay\Sell\Marketing\V1\Model\BulkAdUpdateStatusResponse' === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, '\TNT\Ebay\Sell\Marketing\V1\Model\BulkAdUpdateStatusResponse', []),
$response->getStatusCode(),
$response->getHeaders(),
];
}
$returnType = '\TNT\Ebay\Sell\Marketing\V1\Model\BulkAdUpdateStatusResponse';
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders(),
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'\TNT\Ebay\Sell\Marketing\V1\Model\BulkAdUpdateStatusResponse',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation bulkUpdateAdsStatusAsync.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created.<br /><br /><span class=\"tablenote\"><b>Note:</b> You can retrieve the campaign IDs for a specified seller using the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a> method.</span> (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\BulkUpdateAdStatusRequest $bulk_update_ad_status_request The bulk request to update the ads. (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function bulkUpdateAdsStatusAsync($campaign_id, $bulk_update_ad_status_request)
{
return $this->bulkUpdateAdsStatusAsyncWithHttpInfo($campaign_id, $bulk_update_ad_status_request)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation bulkUpdateAdsStatusAsyncWithHttpInfo.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created.<br /><br /><span class=\"tablenote\"><b>Note:</b> You can retrieve the campaign IDs for a specified seller using the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a> method.</span> (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\BulkUpdateAdStatusRequest $bulk_update_ad_status_request The bulk request to update the ads. (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function bulkUpdateAdsStatusAsyncWithHttpInfo($campaign_id, $bulk_update_ad_status_request)
{
$returnType = '\TNT\Ebay\Sell\Marketing\V1\Model\BulkAdUpdateStatusResponse';
$request = $this->bulkUpdateAdsStatusRequest($campaign_id, $bulk_update_ad_status_request);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders(),
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(sprintf('[%d] Error connecting to the API (%s)', $statusCode, $exception->getRequest()->getUri()), $statusCode, $response->getHeaders(), (string) $response->getBody(), $exception instanceof \Throwable ? $exception : null);
}
);
}
/**
* Create request for operation 'bulkUpdateAdsStatus'.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created.<br /><br /><span class=\"tablenote\"><b>Note:</b> You can retrieve the campaign IDs for a specified seller using the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a> method.</span> (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\BulkUpdateAdStatusRequest $bulk_update_ad_status_request The bulk request to update the ads. (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Psr7\Request
*/
public function bulkUpdateAdsStatusRequest($campaign_id, $bulk_update_ad_status_request)
{
// 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 bulkUpdateAdsStatus');
}
// Verify the required parameter 'bulk_update_ad_status_request' is set.
if ($bulk_update_ad_status_request === null || (\is_array($bulk_update_ad_status_request) && count($bulk_update_ad_status_request) === 0)) {
throw new \InvalidArgumentException('Missing the required parameter $bulk_update_ad_status_request when calling bulkUpdateAdsStatus');
}
$resourcePath = '/ad_campaign/{campaign_id}/bulk_update_ads_status';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// path params
if ($campaign_id !== null) {
$resourcePath = str_replace(
'{campaign_id}',
ObjectSerializer::toPathValue($campaign_id),
$resourcePath
);
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// For model (json/xml)
if (isset($bulk_update_ad_status_request)) {
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($bulk_update_ad_status_request));
} else {
$httpBody = $bulk_update_ad_status_request;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
foreach ($formParamValueItems as $formParamValueItem) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValueItem,
];
}
}
// For HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// For HTTP post (form)
$httpBody = ObjectSerializer::buildQuery($queryParams);
}
}
// this endpoint requires OAuth (access token)
if (! empty($this->config->getAccessToken())) {
$headers['Authorization'] = 'Bearer '.$this->config->getAccessToken();
}
// this endpoint requires OAuth (access token)
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 = ObjectSerializer::buildQuery($queryParams);
return new Request(
'POST',
$this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation bulkUpdateAdsStatusByListingId.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created.<br /><br /><span class=\"tablenote\"><b>Note:</b> You can retrieve the campaign IDs for a specified seller using the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a> method.</span> (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\BulkUpdateAdStatusByListingIdRequest $bulk_update_ad_status_by_listing_id_request The bulk request to update ads. (required)
*
* @throws \TNT\Ebay\Sell\Marketing\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return \TNT\Ebay\Sell\Marketing\V1\Model\BulkAdUpdateStatusByListingIdResponse
*/
public function bulkUpdateAdsStatusByListingId($campaign_id, $bulk_update_ad_status_by_listing_id_request)
{
[$response] = $this->bulkUpdateAdsStatusByListingIdWithHttpInfo($campaign_id, $bulk_update_ad_status_by_listing_id_request);
return $response;
}
/**
* Operation bulkUpdateAdsStatusByListingIdWithHttpInfo.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created.<br /><br /><span class=\"tablenote\"><b>Note:</b> You can retrieve the campaign IDs for a specified seller using the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a> method.</span> (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\BulkUpdateAdStatusByListingIdRequest $bulk_update_ad_status_by_listing_id_request The bulk request to update ads. (required)
*
* @throws \TNT\Ebay\Sell\Marketing\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return array of \TNT\Ebay\Sell\Marketing\V1\Model\BulkAdUpdateStatusByListingIdResponse, HTTP status code, HTTP response headers (array of strings)
*/
public function bulkUpdateAdsStatusByListingIdWithHttpInfo($campaign_id, $bulk_update_ad_status_by_listing_id_request)
{
$request = $this->bulkUpdateAdsStatusByListingIdRequest($campaign_id, $bulk_update_ad_status_by_listing_id_request);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null, $e);
} catch (ConnectException $e) {
throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), null, null, $e);
} catch (GuzzleException $e) {
throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), null, null, $e);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(sprintf('[%d] Error connecting to the API (%s)', $statusCode, (string) $request->getUri()), $statusCode, $response->getHeaders(), (string) $response->getBody());
}
switch ($statusCode) {
case 200:
if ('\TNT\Ebay\Sell\Marketing\V1\Model\BulkAdUpdateStatusByListingIdResponse' === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, '\TNT\Ebay\Sell\Marketing\V1\Model\BulkAdUpdateStatusByListingIdResponse', []),
$response->getStatusCode(),
$response->getHeaders(),
];
}
$returnType = '\TNT\Ebay\Sell\Marketing\V1\Model\BulkAdUpdateStatusByListingIdResponse';
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders(),
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'\TNT\Ebay\Sell\Marketing\V1\Model\BulkAdUpdateStatusByListingIdResponse',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation bulkUpdateAdsStatusByListingIdAsync.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created.<br /><br /><span class=\"tablenote\"><b>Note:</b> You can retrieve the campaign IDs for a specified seller using the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a> method.</span> (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\BulkUpdateAdStatusByListingIdRequest $bulk_update_ad_status_by_listing_id_request The bulk request to update ads. (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function bulkUpdateAdsStatusByListingIdAsync($campaign_id, $bulk_update_ad_status_by_listing_id_request)
{
return $this->bulkUpdateAdsStatusByListingIdAsyncWithHttpInfo($campaign_id, $bulk_update_ad_status_by_listing_id_request)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation bulkUpdateAdsStatusByListingIdAsyncWithHttpInfo.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created.<br /><br /><span class=\"tablenote\"><b>Note:</b> You can retrieve the campaign IDs for a specified seller using the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a> method.</span> (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\BulkUpdateAdStatusByListingIdRequest $bulk_update_ad_status_by_listing_id_request The bulk request to update ads. (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function bulkUpdateAdsStatusByListingIdAsyncWithHttpInfo($campaign_id, $bulk_update_ad_status_by_listing_id_request)
{
$returnType = '\TNT\Ebay\Sell\Marketing\V1\Model\BulkAdUpdateStatusByListingIdResponse';
$request = $this->bulkUpdateAdsStatusByListingIdRequest($campaign_id, $bulk_update_ad_status_by_listing_id_request);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders(),
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(sprintf('[%d] Error connecting to the API (%s)', $statusCode, $exception->getRequest()->getUri()), $statusCode, $response->getHeaders(), (string) $response->getBody(), $exception instanceof \Throwable ? $exception : null);
}
);
}
/**
* Create request for operation 'bulkUpdateAdsStatusByListingId'.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created.<br /><br /><span class=\"tablenote\"><b>Note:</b> You can retrieve the campaign IDs for a specified seller using the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a> method.</span> (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\BulkUpdateAdStatusByListingIdRequest $bulk_update_ad_status_by_listing_id_request The bulk request to update ads. (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Psr7\Request
*/
public function bulkUpdateAdsStatusByListingIdRequest($campaign_id, $bulk_update_ad_status_by_listing_id_request)
{
// 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 bulkUpdateAdsStatusByListingId');
}
// Verify the required parameter 'bulk_update_ad_status_by_listing_id_request' is set.
if ($bulk_update_ad_status_by_listing_id_request === null || (\is_array($bulk_update_ad_status_by_listing_id_request) && count($bulk_update_ad_status_by_listing_id_request) === 0)) {
throw new \InvalidArgumentException('Missing the required parameter $bulk_update_ad_status_by_listing_id_request when calling bulkUpdateAdsStatusByListingId');
}
$resourcePath = '/ad_campaign/{campaign_id}/bulk_update_ads_status_by_listing_id';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// path params
if ($campaign_id !== null) {
$resourcePath = str_replace(
'{campaign_id}',
ObjectSerializer::toPathValue($campaign_id),
$resourcePath
);
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// For model (json/xml)
if (isset($bulk_update_ad_status_by_listing_id_request)) {
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($bulk_update_ad_status_by_listing_id_request));
} else {
$httpBody = $bulk_update_ad_status_by_listing_id_request;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
foreach ($formParamValueItems as $formParamValueItem) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValueItem,
];
}
}
// For HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// For HTTP post (form)
$httpBody = ObjectSerializer::buildQuery($queryParams);
}
}
// this endpoint requires OAuth (access token)
if (! empty($this->config->getAccessToken())) {
$headers['Authorization'] = 'Bearer '.$this->config->getAccessToken();
}
// this endpoint requires OAuth (access token)
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 = ObjectSerializer::buildQuery($queryParams);
return new Request(
'POST',
$this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createAdByListingId.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created.<br /><br /><span class=\"tablenote\"><b>Note:</b> You can retrieve the campaign IDs for a specified seller using the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a> method.</span> (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\CreateAdRequest $create_ad_request This request object defines the fields used in the <b>createAdByListingId</b> request. (required)
*
* @throws \TNT\Ebay\Sell\Marketing\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return object
*/
public function createAdByListingId($campaign_id, $create_ad_request)
{
[$response] = $this->createAdByListingIdWithHttpInfo($campaign_id, $create_ad_request);
return $response;
}
/**
* Operation createAdByListingIdWithHttpInfo.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created.<br /><br /><span class=\"tablenote\"><b>Note:</b> You can retrieve the campaign IDs for a specified seller using the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a> method.</span> (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\CreateAdRequest $create_ad_request This request object defines the fields used in the <b>createAdByListingId</b> request. (required)
*
* @throws \TNT\Ebay\Sell\Marketing\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return array of object, HTTP status code, HTTP response headers (array of strings)
*/
public function createAdByListingIdWithHttpInfo($campaign_id, $create_ad_request)
{
$request = $this->createAdByListingIdRequest($campaign_id, $create_ad_request);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null, $e);
} catch (ConnectException $e) {
throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), null, null, $e);
} catch (GuzzleException $e) {
throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), null, null, $e);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(sprintf('[%d] Error connecting to the API (%s)', $statusCode, (string) $request->getUri()), $statusCode, $response->getHeaders(), (string) $response->getBody());
}
switch ($statusCode) {
case 201:
if ('object' === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, 'object', []),
$response->getStatusCode(),
$response->getHeaders(),
];
}
$returnType = 'object';
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders(),
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 201:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'object',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createAdByListingIdAsync.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created.<br /><br /><span class=\"tablenote\"><b>Note:</b> You can retrieve the campaign IDs for a specified seller using the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a> method.</span> (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\CreateAdRequest $create_ad_request This request object defines the fields used in the <b>createAdByListingId</b> request. (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createAdByListingIdAsync($campaign_id, $create_ad_request)
{
return $this->createAdByListingIdAsyncWithHttpInfo($campaign_id, $create_ad_request)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createAdByListingIdAsyncWithHttpInfo.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created.<br /><br /><span class=\"tablenote\"><b>Note:</b> You can retrieve the campaign IDs for a specified seller using the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a> method.</span> (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\CreateAdRequest $create_ad_request This request object defines the fields used in the <b>createAdByListingId</b> request. (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createAdByListingIdAsyncWithHttpInfo($campaign_id, $create_ad_request)
{
$returnType = 'object';
$request = $this->createAdByListingIdRequest($campaign_id, $create_ad_request);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders(),
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(sprintf('[%d] Error connecting to the API (%s)', $statusCode, $exception->getRequest()->getUri()), $statusCode, $response->getHeaders(), (string) $response->getBody(), $exception instanceof \Throwable ? $exception : null);
}
);
}
/**
* Create request for operation 'createAdByListingId'.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created.<br /><br /><span class=\"tablenote\"><b>Note:</b> You can retrieve the campaign IDs for a specified seller using the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a> method.</span> (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\CreateAdRequest $create_ad_request This request object defines the fields used in the <b>createAdByListingId</b> request. (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Psr7\Request
*/
public function createAdByListingIdRequest($campaign_id, $create_ad_request)
{
// 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 createAdByListingId');
}
// Verify the required parameter 'create_ad_request' is set.
if ($create_ad_request === null || (\is_array($create_ad_request) && count($create_ad_request) === 0)) {
throw new \InvalidArgumentException('Missing the required parameter $create_ad_request when calling createAdByListingId');
}
$resourcePath = '/ad_campaign/{campaign_id}/ad';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// path params
if ($campaign_id !== null) {
$resourcePath = str_replace(
'{campaign_id}',
ObjectSerializer::toPathValue($campaign_id),
$resourcePath
);
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// For model (json/xml)
if (isset($create_ad_request)) {
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($create_ad_request));
} else {
$httpBody = $create_ad_request;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
foreach ($formParamValueItems as $formParamValueItem) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValueItem,
];
}
}
// For HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// For HTTP post (form)
$httpBody = ObjectSerializer::buildQuery($queryParams);
}
}
// this endpoint requires OAuth (access token)
if (! empty($this->config->getAccessToken())) {
$headers['Authorization'] = 'Bearer '.$this->config->getAccessToken();
}
// this endpoint requires OAuth (access token)
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 = ObjectSerializer::buildQuery($queryParams);
return new Request(
'POST',
$this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createAdsByInventoryReference.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created.<br /><br /><span class=\"tablenote\"><b>Note:</b> You can retrieve the campaign IDs for a specified seller using the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a> method.</span> (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\CreateAdsByInventoryReferenceRequest $create_ads_by_inventory_reference_request This request object defines the fields used in the <b>createAdsByInventoryReference</b> request. (required)
*
* @throws \TNT\Ebay\Sell\Marketing\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return \TNT\Ebay\Sell\Marketing\V1\Model\AdReferences
*/
public function createAdsByInventoryReference($campaign_id, $create_ads_by_inventory_reference_request)
{
[$response] = $this->createAdsByInventoryReferenceWithHttpInfo($campaign_id, $create_ads_by_inventory_reference_request);
return $response;
}
/**
* Operation createAdsByInventoryReferenceWithHttpInfo.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created.<br /><br /><span class=\"tablenote\"><b>Note:</b> You can retrieve the campaign IDs for a specified seller using the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a> method.</span> (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\CreateAdsByInventoryReferenceRequest $create_ads_by_inventory_reference_request This request object defines the fields used in the <b>createAdsByInventoryReference</b> request. (required)
*
* @throws \TNT\Ebay\Sell\Marketing\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return array of \TNT\Ebay\Sell\Marketing\V1\Model\AdReferences, HTTP status code, HTTP response headers (array of strings)
*/
public function createAdsByInventoryReferenceWithHttpInfo($campaign_id, $create_ads_by_inventory_reference_request)
{
$request = $this->createAdsByInventoryReferenceRequest($campaign_id, $create_ads_by_inventory_reference_request);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null, $e);
} catch (ConnectException $e) {
throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), null, null, $e);
} catch (GuzzleException $e) {
throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), null, null, $e);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(sprintf('[%d] Error connecting to the API (%s)', $statusCode, (string) $request->getUri()), $statusCode, $response->getHeaders(), (string) $response->getBody());
}
switch ($statusCode) {
case 201:
if ('\TNT\Ebay\Sell\Marketing\V1\Model\AdReferences' === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, '\TNT\Ebay\Sell\Marketing\V1\Model\AdReferences', []),
$response->getStatusCode(),
$response->getHeaders(),
];
}
$returnType = '\TNT\Ebay\Sell\Marketing\V1\Model\AdReferences';
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders(),
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 201:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'\TNT\Ebay\Sell\Marketing\V1\Model\AdReferences',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createAdsByInventoryReferenceAsync.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created.<br /><br /><span class=\"tablenote\"><b>Note:</b> You can retrieve the campaign IDs for a specified seller using the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a> method.</span> (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\CreateAdsByInventoryReferenceRequest $create_ads_by_inventory_reference_request This request object defines the fields used in the <b>createAdsByInventoryReference</b> request. (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createAdsByInventoryReferenceAsync($campaign_id, $create_ads_by_inventory_reference_request)
{
return $this->createAdsByInventoryReferenceAsyncWithHttpInfo($campaign_id, $create_ads_by_inventory_reference_request)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createAdsByInventoryReferenceAsyncWithHttpInfo.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created.<br /><br /><span class=\"tablenote\"><b>Note:</b> You can retrieve the campaign IDs for a specified seller using the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a> method.</span> (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\CreateAdsByInventoryReferenceRequest $create_ads_by_inventory_reference_request This request object defines the fields used in the <b>createAdsByInventoryReference</b> request. (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createAdsByInventoryReferenceAsyncWithHttpInfo($campaign_id, $create_ads_by_inventory_reference_request)
{
$returnType = '\TNT\Ebay\Sell\Marketing\V1\Model\AdReferences';
$request = $this->createAdsByInventoryReferenceRequest($campaign_id, $create_ads_by_inventory_reference_request);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders(),
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(sprintf('[%d] Error connecting to the API (%s)', $statusCode, $exception->getRequest()->getUri()), $statusCode, $response->getHeaders(), (string) $response->getBody(), $exception instanceof \Throwable ? $exception : null);
}
);
}
/**
* Create request for operation 'createAdsByInventoryReference'.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created.<br /><br /><span class=\"tablenote\"><b>Note:</b> You can retrieve the campaign IDs for a specified seller using the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a> method.</span> (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\CreateAdsByInventoryReferenceRequest $create_ads_by_inventory_reference_request This request object defines the fields used in the <b>createAdsByInventoryReference</b> request. (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Psr7\Request
*/
public function createAdsByInventoryReferenceRequest($campaign_id, $create_ads_by_inventory_reference_request)
{
// 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 createAdsByInventoryReference');
}
// Verify the required parameter 'create_ads_by_inventory_reference_request' is set.
if ($create_ads_by_inventory_reference_request === null || (\is_array($create_ads_by_inventory_reference_request) && count($create_ads_by_inventory_reference_request) === 0)) {
throw new \InvalidArgumentException('Missing the required parameter $create_ads_by_inventory_reference_request when calling createAdsByInventoryReference');
}
$resourcePath = '/ad_campaign/{campaign_id}/create_ads_by_inventory_reference';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// path params
if ($campaign_id !== null) {
$resourcePath = str_replace(
'{campaign_id}',
ObjectSerializer::toPathValue($campaign_id),
$resourcePath
);
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// For model (json/xml)
if (isset($create_ads_by_inventory_reference_request)) {
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($create_ads_by_inventory_reference_request));
} else {
$httpBody = $create_ads_by_inventory_reference_request;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
foreach ($formParamValueItems as $formParamValueItem) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValueItem,
];
}
}
// For HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// For HTTP post (form)
$httpBody = ObjectSerializer::buildQuery($queryParams);
}
}
// this endpoint requires OAuth (access token)
if (! empty($this->config->getAccessToken())) {
$headers['Authorization'] = 'Bearer '.$this->config->getAccessToken();
}
// this endpoint requires OAuth (access token)
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 = ObjectSerializer::buildQuery($queryParams);
return new Request(
'POST',
$this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation deleteAd.
*
* @param string $ad_id Identifier of an ad. This ID was generated when the ad was created. (required)
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created.<br /><br /><span class=\"tablenote\"><b>Note:</b> You can retrieve the campaign IDs for a specified seller using the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a> method.</span> (required)
*
* @throws \TNT\Ebay\Sell\Marketing\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return void
*/
public function deleteAd($ad_id, $campaign_id)
{
$this->deleteAdWithHttpInfo($ad_id, $campaign_id);
}
/**
* Operation deleteAdWithHttpInfo.
*
* @param string $ad_id Identifier of an ad. This ID was generated when the ad was created. (required)
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created.<br /><br /><span class=\"tablenote\"><b>Note:</b> You can retrieve the campaign IDs for a specified seller using the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a> method.</span> (required)
*
* @throws \TNT\Ebay\Sell\Marketing\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return array of null, HTTP status code, HTTP response headers (array of strings)
*/
public function deleteAdWithHttpInfo($ad_id, $campaign_id)
{
$request = $this->deleteAdRequest($ad_id, $campaign_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null, $e);
} catch (ConnectException $e) {
throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), null, null, $e);
} catch (GuzzleException $e) {
throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), null, null, $e);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(sprintf('[%d] Error connecting to the API (%s)', $statusCode, (string) $request->getUri()), $statusCode, $response->getHeaders(), (string) $response->getBody());
}
return [null, $statusCode, $response->getHeaders()];
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
/**
* Operation deleteAdAsync.
*
* @param string $ad_id Identifier of an ad. This ID was generated when the ad was created. (required)
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created.<br /><br /><span class=\"tablenote\"><b>Note:</b> You can retrieve the campaign IDs for a specified seller using the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a> method.</span> (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function deleteAdAsync($ad_id, $campaign_id)
{
return $this->deleteAdAsyncWithHttpInfo($ad_id, $campaign_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation deleteAdAsyncWithHttpInfo.
*
* @param string $ad_id Identifier of an ad. This ID was generated when the ad was created. (required)
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created.<br /><br /><span class=\"tablenote\"><b>Note:</b> You can retrieve the campaign IDs for a specified seller using the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a> method.</span> (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function deleteAdAsyncWithHttpInfo($ad_id, $campaign_id)
{
$returnType = '';
$request = $this->deleteAdRequest($ad_id, $campaign_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) {
return [null, $response->getStatusCode(), $response->getHeaders()];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(sprintf('[%d] Error connecting to the API (%s)', $statusCode, $exception->getRequest()->getUri()), $statusCode, $response->getHeaders(), (string) $response->getBody(), $exception instanceof \Throwable ? $exception : null);
}
);
}
/**
* Create request for operation 'deleteAd'.
*
* @param string $ad_id Identifier of an ad. This ID was generated when the ad was created. (required)
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created.<br /><br /><span class=\"tablenote\"><b>Note:</b> You can retrieve the campaign IDs for a specified seller using the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a> method.</span> (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Psr7\Request
*/
public function deleteAdRequest($ad_id, $campaign_id)
{
// Verify the required parameter 'ad_id' is set.
if ($ad_id === null || (\is_array($ad_id) && count($ad_id) === 0)) {
throw new \InvalidArgumentException('Missing the required parameter $ad_id when calling deleteAd');
}
// 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 deleteAd');
}
$resourcePath = '/ad_campaign/{campaign_id}/ad/{ad_id}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// path params
if ($ad_id !== null) {
$resourcePath = str_replace(
'{ad_id}',
ObjectSerializer::toPathValue($ad_id),
$resourcePath
);
}
// path params
if ($campaign_id !== null) {
$resourcePath = str_replace(
'{campaign_id}',
ObjectSerializer::toPathValue($campaign_id),
$resourcePath
);
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
[]
);
} else {
$headers = $this->headerSelector->selectHeaders(
[],
[]
);
}
// For model (json/xml)
if (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
foreach ($formParamValueItems as $formParamValueItem) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValueItem,
];
}
}
// For HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// For HTTP post (form)
$httpBody = ObjectSerializer::buildQuery($queryParams);
}
}
// this endpoint requires OAuth (access token)
if (! empty($this->config->getAccessToken())) {
$headers['Authorization'] = 'Bearer '.$this->config->getAccessToken();
}
// this endpoint requires OAuth (access token)
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 = ObjectSerializer::buildQuery($queryParams);
return new Request(
'DELETE',
$this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation deleteAdsByInventoryReference.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created.<br /><br /><span class=\"tablenote\"><b>Note:</b> You can retrieve the campaign IDs for a specified seller using the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a> method.</span> (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\DeleteAdsByInventoryReferenceRequest $delete_ads_by_inventory_reference_request This request object defines the fields for the <b>deleteAdsByInventoryReference</b> request. (required)
*
* @throws \TNT\Ebay\Sell\Marketing\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return \TNT\Ebay\Sell\Marketing\V1\Model\AdIds
*/
public function deleteAdsByInventoryReference($campaign_id, $delete_ads_by_inventory_reference_request)
{
[$response] = $this->deleteAdsByInventoryReferenceWithHttpInfo($campaign_id, $delete_ads_by_inventory_reference_request);
return $response;
}
/**
* Operation deleteAdsByInventoryReferenceWithHttpInfo.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created.<br /><br /><span class=\"tablenote\"><b>Note:</b> You can retrieve the campaign IDs for a specified seller using the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a> method.</span> (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\DeleteAdsByInventoryReferenceRequest $delete_ads_by_inventory_reference_request This request object defines the fields for the <b>deleteAdsByInventoryReference</b> request. (required)
*
* @throws \TNT\Ebay\Sell\Marketing\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return array of \TNT\Ebay\Sell\Marketing\V1\Model\AdIds, HTTP status code, HTTP response headers (array of strings)
*/
public function deleteAdsByInventoryReferenceWithHttpInfo($campaign_id, $delete_ads_by_inventory_reference_request)
{
$request = $this->deleteAdsByInventoryReferenceRequest($campaign_id, $delete_ads_by_inventory_reference_request);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null, $e);
} catch (ConnectException $e) {
throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), null, null, $e);
} catch (GuzzleException $e) {
throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), null, null, $e);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(sprintf('[%d] Error connecting to the API (%s)', $statusCode, (string) $request->getUri()), $statusCode, $response->getHeaders(), (string) $response->getBody());
}
switch ($statusCode) {
case 200:
if ('\TNT\Ebay\Sell\Marketing\V1\Model\AdIds' === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, '\TNT\Ebay\Sell\Marketing\V1\Model\AdIds', []),
$response->getStatusCode(),
$response->getHeaders(),
];
}
$returnType = '\TNT\Ebay\Sell\Marketing\V1\Model\AdIds';
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders(),
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'\TNT\Ebay\Sell\Marketing\V1\Model\AdIds',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation deleteAdsByInventoryReferenceAsync.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created.<br /><br /><span class=\"tablenote\"><b>Note:</b> You can retrieve the campaign IDs for a specified seller using the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a> method.</span> (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\DeleteAdsByInventoryReferenceRequest $delete_ads_by_inventory_reference_request This request object defines the fields for the <b>deleteAdsByInventoryReference</b> request. (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function deleteAdsByInventoryReferenceAsync($campaign_id, $delete_ads_by_inventory_reference_request)
{
return $this->deleteAdsByInventoryReferenceAsyncWithHttpInfo($campaign_id, $delete_ads_by_inventory_reference_request)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation deleteAdsByInventoryReferenceAsyncWithHttpInfo.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created.<br /><br /><span class=\"tablenote\"><b>Note:</b> You can retrieve the campaign IDs for a specified seller using the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a> method.</span> (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\DeleteAdsByInventoryReferenceRequest $delete_ads_by_inventory_reference_request This request object defines the fields for the <b>deleteAdsByInventoryReference</b> request. (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function deleteAdsByInventoryReferenceAsyncWithHttpInfo($campaign_id, $delete_ads_by_inventory_reference_request)
{
$returnType = '\TNT\Ebay\Sell\Marketing\V1\Model\AdIds';
$request = $this->deleteAdsByInventoryReferenceRequest($campaign_id, $delete_ads_by_inventory_reference_request);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders(),
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(sprintf('[%d] Error connecting to the API (%s)', $statusCode, $exception->getRequest()->getUri()), $statusCode, $response->getHeaders(), (string) $response->getBody(), $exception instanceof \Throwable ? $exception : null);
}
);
}
/**
* Create request for operation 'deleteAdsByInventoryReference'.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created.<br /><br /><span class=\"tablenote\"><b>Note:</b> You can retrieve the campaign IDs for a specified seller using the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a> method.</span> (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\DeleteAdsByInventoryReferenceRequest $delete_ads_by_inventory_reference_request This request object defines the fields for the <b>deleteAdsByInventoryReference</b> request. (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Psr7\Request
*/
public function deleteAdsByInventoryReferenceRequest($campaign_id, $delete_ads_by_inventory_reference_request)
{
// 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 deleteAdsByInventoryReference');
}
// Verify the required parameter 'delete_ads_by_inventory_reference_request' is set.
if ($delete_ads_by_inventory_reference_request === null || (\is_array($delete_ads_by_inventory_reference_request) && count($delete_ads_by_inventory_reference_request) === 0)) {
throw new \InvalidArgumentException('Missing the required parameter $delete_ads_by_inventory_reference_request when calling deleteAdsByInventoryReference');
}
$resourcePath = '/ad_campaign/{campaign_id}/delete_ads_by_inventory_reference';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// path params
if ($campaign_id !== null) {
$resourcePath = str_replace(
'{campaign_id}',
ObjectSerializer::toPathValue($campaign_id),
$resourcePath
);
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// For model (json/xml)
if (isset($delete_ads_by_inventory_reference_request)) {
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($delete_ads_by_inventory_reference_request));
} else {
$httpBody = $delete_ads_by_inventory_reference_request;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
foreach ($formParamValueItems as $formParamValueItem) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValueItem,
];
}
}
// For HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// For HTTP post (form)
$httpBody = ObjectSerializer::buildQuery($queryParams);
}
}
// this endpoint requires OAuth (access token)
if (! empty($this->config->getAccessToken())) {
$headers['Authorization'] = 'Bearer '.$this->config->getAccessToken();
}
// this endpoint requires OAuth (access token)
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 = ObjectSerializer::buildQuery($queryParams);
return new Request(
'POST',
$this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getAd.
*
* @param string $ad_id A unique identifier for an ad. This ID is generated when the ad is created. (required)
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created.<br /><br /><span class=\"tablenote\"><b>Note:</b> You can retrieve the campaign IDs for a specified seller using the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a> method.</span> (required)
*
* @throws \TNT\Ebay\Sell\Marketing\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return \TNT\Ebay\Sell\Marketing\V1\Model\Ad
*/
public function getAd($ad_id, $campaign_id)
{
[$response] = $this->getAdWithHttpInfo($ad_id, $campaign_id);
return $response;
}
/**
* Operation getAdWithHttpInfo.
*
* @param string $ad_id A unique identifier for an ad. This ID is generated when the ad is created. (required)
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created.<br /><br /><span class=\"tablenote\"><b>Note:</b> You can retrieve the campaign IDs for a specified seller using the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a> method.</span> (required)
*
* @throws \TNT\Ebay\Sell\Marketing\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return array of \TNT\Ebay\Sell\Marketing\V1\Model\Ad, HTTP status code, HTTP response headers (array of strings)
*/
public function getAdWithHttpInfo($ad_id, $campaign_id)
{
$request = $this->getAdRequest($ad_id, $campaign_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null, $e);
} catch (ConnectException $e) {
throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), null, null, $e);
} catch (GuzzleException $e) {
throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), null, null, $e);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(sprintf('[%d] Error connecting to the API (%s)', $statusCode, (string) $request->getUri()), $statusCode, $response->getHeaders(), (string) $response->getBody());
}
switch ($statusCode) {
case 200:
if ('\TNT\Ebay\Sell\Marketing\V1\Model\Ad' === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, '\TNT\Ebay\Sell\Marketing\V1\Model\Ad', []),
$response->getStatusCode(),
$response->getHeaders(),
];
}
$returnType = '\TNT\Ebay\Sell\Marketing\V1\Model\Ad';
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders(),
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'\TNT\Ebay\Sell\Marketing\V1\Model\Ad',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getAdAsync.
*
* @param string $ad_id A unique identifier for an ad. This ID is generated when the ad is created. (required)
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created.<br /><br /><span class=\"tablenote\"><b>Note:</b> You can retrieve the campaign IDs for a specified seller using the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a> method.</span> (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getAdAsync($ad_id, $campaign_id)
{
return $this->getAdAsyncWithHttpInfo($ad_id, $campaign_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getAdAsyncWithHttpInfo.
*
* @param string $ad_id A unique identifier for an ad. This ID is generated when the ad is created. (required)
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created.<br /><br /><span class=\"tablenote\"><b>Note:</b> You can retrieve the campaign IDs for a specified seller using the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a> method.</span> (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getAdAsyncWithHttpInfo($ad_id, $campaign_id)
{
$returnType = '\TNT\Ebay\Sell\Marketing\V1\Model\Ad';
$request = $this->getAdRequest($ad_id, $campaign_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders(),
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(sprintf('[%d] Error connecting to the API (%s)', $statusCode, $exception->getRequest()->getUri()), $statusCode, $response->getHeaders(), (string) $response->getBody(), $exception instanceof \Throwable ? $exception : null);
}
);
}
/**
* Create request for operation 'getAd'.
*
* @param string $ad_id A unique identifier for an ad. This ID is generated when the ad is created. (required)
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created.<br /><br /><span class=\"tablenote\"><b>Note:</b> You can retrieve the campaign IDs for a specified seller using the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a> method.</span> (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Psr7\Request
*/
public function getAdRequest($ad_id, $campaign_id)
{
// Verify the required parameter 'ad_id' is set.
if ($ad_id === null || (\is_array($ad_id) && count($ad_id) === 0)) {
throw new \InvalidArgumentException('Missing the required parameter $ad_id when calling getAd');
}
// 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 getAd');
}
$resourcePath = '/ad_campaign/{campaign_id}/ad/{ad_id}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// path params
if ($ad_id !== null) {
$resourcePath = str_replace(
'{ad_id}',
ObjectSerializer::toPathValue($ad_id),
$resourcePath
);
}
// path params
if ($campaign_id !== null) {
$resourcePath = str_replace(
'{campaign_id}',
ObjectSerializer::toPathValue($campaign_id),
$resourcePath
);
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// For model (json/xml)
if (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
foreach ($formParamValueItems as $formParamValueItem) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValueItem,
];
}
}
// For HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// For HTTP post (form)
$httpBody = ObjectSerializer::buildQuery($queryParams);
}
}
// this endpoint requires OAuth (access token)
if (! empty($this->config->getAccessToken())) {
$headers['Authorization'] = 'Bearer '.$this->config->getAccessToken();
}
// this endpoint requires OAuth (access token)
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 = ObjectSerializer::buildQuery($queryParams);
return new Request(
'GET',
$this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getAds.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created.<br /><br /><span class=\"tablenote\"><b>Note:</b> You can retrieve the campaign IDs for a specified seller using the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a> method.</span> (required)
* @param string $ad_group_ids A comma-separated list of ad group IDs. The results will be filtered to only include active ads for these ad groups. Call <a href=\"/api-docs/sell/marketing/resources/adgroup/methods/getAdGroups\">getAdGroups</a> to retrieve the ad group ID for the ad group.<br /><br /><span class=\"tablenote\"><b>Note:</b> This field only applies to the Cost Per Click (CPC) funding model; it does not apply to the Cost Per Sale (CPS) funding model.</span> (optional)
* @param string $ad_status A comma-separated list of ad statuses. The results will be filtered to only include the given statuses of the ad. If none are provided, all ads are returned. (optional)
* @param string $limit Specifies the maximum number of ads to return on a page in the paginated response. <p><b>Default: </b>10 <br><b>Maximum:</b> 500</p> (optional)
* @param string $listing_ids A comma-separated list of listing IDs. The response includes only active ads (ads associated with a RUNNING campaign). The results do not include listing IDs that are excluded by other conditions. (optional)
* @param string $offset Specifies the number of ads to skip in the result set before returning the first ad in the paginated response. <p>Combine <b>offset</b> with the <b>limit</b> query parameter to control the items returned in the response. For example, if you supply an <b>offset</b> of <code>0</code> and a <b>limit</b> of <code>10</code>, the first page of the response contains the first 10 items from the complete list of items retrieved by the call. If <b>offset</b> is <code>10</code> and <b>limit</b> is <code>20</code>, the first page of the response contains items 11-30 from the complete result set.</p> <p><b>Default:</b> 0</p> (optional)
*
* @throws \TNT\Ebay\Sell\Marketing\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return \TNT\Ebay\Sell\Marketing\V1\Model\AdPagedCollectionResponse
*/
public function getAds($campaign_id, $ad_group_ids = null, $ad_status = null, $limit = null, $listing_ids = null, $offset = null)
{
[$response] = $this->getAdsWithHttpInfo($campaign_id, $ad_group_ids, $ad_status, $limit, $listing_ids, $offset);
return $response;
}
/**
* Operation getAdsWithHttpInfo.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created.<br /><br /><span class=\"tablenote\"><b>Note:</b> You can retrieve the campaign IDs for a specified seller using the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a> method.</span> (required)
* @param string $ad_group_ids A comma-separated list of ad group IDs. The results will be filtered to only include active ads for these ad groups. Call <a href=\"/api-docs/sell/marketing/resources/adgroup/methods/getAdGroups\">getAdGroups</a> to retrieve the ad group ID for the ad group.<br /><br /><span class=\"tablenote\"><b>Note:</b> This field only applies to the Cost Per Click (CPC) funding model; it does not apply to the Cost Per Sale (CPS) funding model.</span> (optional)
* @param string $ad_status A comma-separated list of ad statuses. The results will be filtered to only include the given statuses of the ad. If none are provided, all ads are returned. (optional)
* @param string $limit Specifies the maximum number of ads to return on a page in the paginated response. <p><b>Default: </b>10 <br><b>Maximum:</b> 500</p> (optional)
* @param string $listing_ids A comma-separated list of listing IDs. The response includes only active ads (ads associated with a RUNNING campaign). The results do not include listing IDs that are excluded by other conditions. (optional)
* @param string $offset Specifies the number of ads to skip in the result set before returning the first ad in the paginated response. <p>Combine <b>offset</b> with the <b>limit</b> query parameter to control the items returned in the response. For example, if you supply an <b>offset</b> of <code>0</code> and a <b>limit</b> of <code>10</code>, the first page of the response contains the first 10 items from the complete list of items retrieved by the call. If <b>offset</b> is <code>10</code> and <b>limit</b> is <code>20</code>, the first page of the response contains items 11-30 from the complete result set.</p> <p><b>Default:</b> 0</p> (optional)
*
* @throws \TNT\Ebay\Sell\Marketing\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return array of \TNT\Ebay\Sell\Marketing\V1\Model\AdPagedCollectionResponse, HTTP status code, HTTP response headers (array of strings)
*/
public function getAdsWithHttpInfo($campaign_id, $ad_group_ids = null, $ad_status = null, $limit = null, $listing_ids = null, $offset = null)
{
$request = $this->getAdsRequest($campaign_id, $ad_group_ids, $ad_status, $limit, $listing_ids, $offset);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null, $e);
} catch (ConnectException $e) {
throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), null, null, $e);
} catch (GuzzleException $e) {
throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), null, null, $e);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(sprintf('[%d] Error connecting to the API (%s)', $statusCode, (string) $request->getUri()), $statusCode, $response->getHeaders(), (string) $response->getBody());
}
switch ($statusCode) {
case 200:
if ('\TNT\Ebay\Sell\Marketing\V1\Model\AdPagedCollectionResponse' === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, '\TNT\Ebay\Sell\Marketing\V1\Model\AdPagedCollectionResponse', []),
$response->getStatusCode(),
$response->getHeaders(),
];
}
$returnType = '\TNT\Ebay\Sell\Marketing\V1\Model\AdPagedCollectionResponse';
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders(),
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'\TNT\Ebay\Sell\Marketing\V1\Model\AdPagedCollectionResponse',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getAdsAsync.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created.<br /><br /><span class=\"tablenote\"><b>Note:</b> You can retrieve the campaign IDs for a specified seller using the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a> method.</span> (required)
* @param string $ad_group_ids A comma-separated list of ad group IDs. The results will be filtered to only include active ads for these ad groups. Call <a href=\"/api-docs/sell/marketing/resources/adgroup/methods/getAdGroups\">getAdGroups</a> to retrieve the ad group ID for the ad group.<br /><br /><span class=\"tablenote\"><b>Note:</b> This field only applies to the Cost Per Click (CPC) funding model; it does not apply to the Cost Per Sale (CPS) funding model.</span> (optional)
* @param string $ad_status A comma-separated list of ad statuses. The results will be filtered to only include the given statuses of the ad. If none are provided, all ads are returned. (optional)
* @param string $limit Specifies the maximum number of ads to return on a page in the paginated response. <p><b>Default: </b>10 <br><b>Maximum:</b> 500</p> (optional)
* @param string $listing_ids A comma-separated list of listing IDs. The response includes only active ads (ads associated with a RUNNING campaign). The results do not include listing IDs that are excluded by other conditions. (optional)
* @param string $offset Specifies the number of ads to skip in the result set before returning the first ad in the paginated response. <p>Combine <b>offset</b> with the <b>limit</b> query parameter to control the items returned in the response. For example, if you supply an <b>offset</b> of <code>0</code> and a <b>limit</b> of <code>10</code>, the first page of the response contains the first 10 items from the complete list of items retrieved by the call. If <b>offset</b> is <code>10</code> and <b>limit</b> is <code>20</code>, the first page of the response contains items 11-30 from the complete result set.</p> <p><b>Default:</b> 0</p> (optional)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getAdsAsync($campaign_id, $ad_group_ids = null, $ad_status = null, $limit = null, $listing_ids = null, $offset = null)
{
return $this->getAdsAsyncWithHttpInfo($campaign_id, $ad_group_ids, $ad_status, $limit, $listing_ids, $offset)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getAdsAsyncWithHttpInfo.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created.<br /><br /><span class=\"tablenote\"><b>Note:</b> You can retrieve the campaign IDs for a specified seller using the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a> method.</span> (required)
* @param string $ad_group_ids A comma-separated list of ad group IDs. The results will be filtered to only include active ads for these ad groups. Call <a href=\"/api-docs/sell/marketing/resources/adgroup/methods/getAdGroups\">getAdGroups</a> to retrieve the ad group ID for the ad group.<br /><br /><span class=\"tablenote\"><b>Note:</b> This field only applies to the Cost Per Click (CPC) funding model; it does not apply to the Cost Per Sale (CPS) funding model.</span> (optional)
* @param string $ad_status A comma-separated list of ad statuses. The results will be filtered to only include the given statuses of the ad. If none are provided, all ads are returned. (optional)
* @param string $limit Specifies the maximum number of ads to return on a page in the paginated response. <p><b>Default: </b>10 <br><b>Maximum:</b> 500</p> (optional)
* @param string $listing_ids A comma-separated list of listing IDs. The response includes only active ads (ads associated with a RUNNING campaign). The results do not include listing IDs that are excluded by other conditions. (optional)
* @param string $offset Specifies the number of ads to skip in the result set before returning the first ad in the paginated response. <p>Combine <b>offset</b> with the <b>limit</b> query parameter to control the items returned in the response. For example, if you supply an <b>offset</b> of <code>0</code> and a <b>limit</b> of <code>10</code>, the first page of the response contains the first 10 items from the complete list of items retrieved by the call. If <b>offset</b> is <code>10</code> and <b>limit</b> is <code>20</code>, the first page of the response contains items 11-30 from the complete result set.</p> <p><b>Default:</b> 0</p> (optional)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getAdsAsyncWithHttpInfo($campaign_id, $ad_group_ids = null, $ad_status = null, $limit = null, $listing_ids = null, $offset = null)
{
$returnType = '\TNT\Ebay\Sell\Marketing\V1\Model\AdPagedCollectionResponse';
$request = $this->getAdsRequest($campaign_id, $ad_group_ids, $ad_status, $limit, $listing_ids, $offset);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders(),
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(sprintf('[%d] Error connecting to the API (%s)', $statusCode, $exception->getRequest()->getUri()), $statusCode, $response->getHeaders(), (string) $response->getBody(), $exception instanceof \Throwable ? $exception : null);
}
);
}
/**
* Create request for operation 'getAds'.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created.<br /><br /><span class=\"tablenote\"><b>Note:</b> You can retrieve the campaign IDs for a specified seller using the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a> method.</span> (required)
* @param string $ad_group_ids A comma-separated list of ad group IDs. The results will be filtered to only include active ads for these ad groups. Call <a href=\"/api-docs/sell/marketing/resources/adgroup/methods/getAdGroups\">getAdGroups</a> to retrieve the ad group ID for the ad group.<br /><br /><span class=\"tablenote\"><b>Note:</b> This field only applies to the Cost Per Click (CPC) funding model; it does not apply to the Cost Per Sale (CPS) funding model.</span> (optional)
* @param string $ad_status A comma-separated list of ad statuses. The results will be filtered to only include the given statuses of the ad. If none are provided, all ads are returned. (optional)
* @param string $limit Specifies the maximum number of ads to return on a page in the paginated response. <p><b>Default: </b>10 <br><b>Maximum:</b> 500</p> (optional)
* @param string $listing_ids A comma-separated list of listing IDs. The response includes only active ads (ads associated with a RUNNING campaign). The results do not include listing IDs that are excluded by other conditions. (optional)
* @param string $offset Specifies the number of ads to skip in the result set before returning the first ad in the paginated response. <p>Combine <b>offset</b> with the <b>limit</b> query parameter to control the items returned in the response. For example, if you supply an <b>offset</b> of <code>0</code> and a <b>limit</b> of <code>10</code>, the first page of the response contains the first 10 items from the complete list of items retrieved by the call. If <b>offset</b> is <code>10</code> and <b>limit</b> is <code>20</code>, the first page of the response contains items 11-30 from the complete result set.</p> <p><b>Default:</b> 0</p> (optional)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Psr7\Request
*/
public function getAdsRequest($campaign_id, $ad_group_ids = null, $ad_status = null, $limit = null, $listing_ids = null, $offset = 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 getAds');
}
$resourcePath = '/ad_campaign/{campaign_id}/ad';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
$ad_group_ids,
'ad_group_ids', // param base name
'string', // openApiType
'form', // style
true // explode
) ?? []);
// query params
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
$ad_status,
'ad_status', // param base name
'string', // openApiType
'form', // style
true // explode
) ?? []);
// query params
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
$limit,
'limit', // param base name
'string', // openApiType
'form', // style
true // explode
) ?? []);
// query params
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
$listing_ids,
'listing_ids', // param base name
'string', // openApiType
'form', // style
true // explode
) ?? []);
// query params
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
$offset,
'offset', // param base name
'string', // openApiType
'form', // style
true // explode
) ?? []);
// path params
if ($campaign_id !== null) {
$resourcePath = str_replace(
'{campaign_id}',
ObjectSerializer::toPathValue($campaign_id),
$resourcePath
);
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// For model (json/xml)
if (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
foreach ($formParamValueItems as $formParamValueItem) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValueItem,
];
}
}
// For HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// For HTTP post (form)
$httpBody = ObjectSerializer::buildQuery($queryParams);
}
}
// this endpoint requires OAuth (access token)
if (! empty($this->config->getAccessToken())) {
$headers['Authorization'] = 'Bearer '.$this->config->getAccessToken();
}
// this endpoint requires OAuth (access token)
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 = ObjectSerializer::buildQuery($queryParams);
return new Request(
'GET',
$this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getAdsByInventoryReference.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created.<br /><br /><span class=\"tablenote\"><b>Note:</b> You can retrieve the campaign IDs for a specified seller using the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a> method.</span> (required)
* @param string $inventory_reference_id The inventory reference ID associated with the ad you want returned. A seller's inventory reference ID is the ID of either a listing or the ID of an inventory item group (the parent of a multi-variation listing, such as a shirt that is available in multiple sizes and colors). You must always supply in both an <b>inventory_reference_id</b> and an <b>inventory_reference_type</b>. (required)
* @param string $inventory_reference_type The type of the inventory reference ID. Set this value to either <code>INVENTORY_ITEM</CODE> (a single listing) or <code>INVENTORY_ITEM_GROUP</CODE> (a multi-variation listing). You must always pass in both an <b>inventory_reference_id</b> and an <b>inventory_reference_type</b>. (required)
*
* @throws \TNT\Ebay\Sell\Marketing\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return \TNT\Ebay\Sell\Marketing\V1\Model\Ads
*/
public function getAdsByInventoryReference($campaign_id, $inventory_reference_id, $inventory_reference_type)
{
[$response] = $this->getAdsByInventoryReferenceWithHttpInfo($campaign_id, $inventory_reference_id, $inventory_reference_type);
return $response;
}
/**
* Operation getAdsByInventoryReferenceWithHttpInfo.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created.<br /><br /><span class=\"tablenote\"><b>Note:</b> You can retrieve the campaign IDs for a specified seller using the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a> method.</span> (required)
* @param string $inventory_reference_id The inventory reference ID associated with the ad you want returned. A seller's inventory reference ID is the ID of either a listing or the ID of an inventory item group (the parent of a multi-variation listing, such as a shirt that is available in multiple sizes and colors). You must always supply in both an <b>inventory_reference_id</b> and an <b>inventory_reference_type</b>. (required)
* @param string $inventory_reference_type The type of the inventory reference ID. Set this value to either <code>INVENTORY_ITEM</CODE> (a single listing) or <code>INVENTORY_ITEM_GROUP</CODE> (a multi-variation listing). You must always pass in both an <b>inventory_reference_id</b> and an <b>inventory_reference_type</b>. (required)
*
* @throws \TNT\Ebay\Sell\Marketing\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return array of \TNT\Ebay\Sell\Marketing\V1\Model\Ads, HTTP status code, HTTP response headers (array of strings)
*/
public function getAdsByInventoryReferenceWithHttpInfo($campaign_id, $inventory_reference_id, $inventory_reference_type)
{
$request = $this->getAdsByInventoryReferenceRequest($campaign_id, $inventory_reference_id, $inventory_reference_type);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null, $e);
} catch (ConnectException $e) {
throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), null, null, $e);
} catch (GuzzleException $e) {
throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), null, null, $e);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(sprintf('[%d] Error connecting to the API (%s)', $statusCode, (string) $request->getUri()), $statusCode, $response->getHeaders(), (string) $response->getBody());
}
switch ($statusCode) {
case 200:
if ('\TNT\Ebay\Sell\Marketing\V1\Model\Ads' === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, '\TNT\Ebay\Sell\Marketing\V1\Model\Ads', []),
$response->getStatusCode(),
$response->getHeaders(),
];
}
$returnType = '\TNT\Ebay\Sell\Marketing\V1\Model\Ads';
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders(),
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'\TNT\Ebay\Sell\Marketing\V1\Model\Ads',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getAdsByInventoryReferenceAsync.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created.<br /><br /><span class=\"tablenote\"><b>Note:</b> You can retrieve the campaign IDs for a specified seller using the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a> method.</span> (required)
* @param string $inventory_reference_id The inventory reference ID associated with the ad you want returned. A seller's inventory reference ID is the ID of either a listing or the ID of an inventory item group (the parent of a multi-variation listing, such as a shirt that is available in multiple sizes and colors). You must always supply in both an <b>inventory_reference_id</b> and an <b>inventory_reference_type</b>. (required)
* @param string $inventory_reference_type The type of the inventory reference ID. Set this value to either <code>INVENTORY_ITEM</CODE> (a single listing) or <code>INVENTORY_ITEM_GROUP</CODE> (a multi-variation listing). You must always pass in both an <b>inventory_reference_id</b> and an <b>inventory_reference_type</b>. (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getAdsByInventoryReferenceAsync($campaign_id, $inventory_reference_id, $inventory_reference_type)
{
return $this->getAdsByInventoryReferenceAsyncWithHttpInfo($campaign_id, $inventory_reference_id, $inventory_reference_type)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getAdsByInventoryReferenceAsyncWithHttpInfo.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created.<br /><br /><span class=\"tablenote\"><b>Note:</b> You can retrieve the campaign IDs for a specified seller using the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a> method.</span> (required)
* @param string $inventory_reference_id The inventory reference ID associated with the ad you want returned. A seller's inventory reference ID is the ID of either a listing or the ID of an inventory item group (the parent of a multi-variation listing, such as a shirt that is available in multiple sizes and colors). You must always supply in both an <b>inventory_reference_id</b> and an <b>inventory_reference_type</b>. (required)
* @param string $inventory_reference_type The type of the inventory reference ID. Set this value to either <code>INVENTORY_ITEM</CODE> (a single listing) or <code>INVENTORY_ITEM_GROUP</CODE> (a multi-variation listing). You must always pass in both an <b>inventory_reference_id</b> and an <b>inventory_reference_type</b>. (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getAdsByInventoryReferenceAsyncWithHttpInfo($campaign_id, $inventory_reference_id, $inventory_reference_type)
{
$returnType = '\TNT\Ebay\Sell\Marketing\V1\Model\Ads';
$request = $this->getAdsByInventoryReferenceRequest($campaign_id, $inventory_reference_id, $inventory_reference_type);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders(),
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(sprintf('[%d] Error connecting to the API (%s)', $statusCode, $exception->getRequest()->getUri()), $statusCode, $response->getHeaders(), (string) $response->getBody(), $exception instanceof \Throwable ? $exception : null);
}
);
}
/**
* Create request for operation 'getAdsByInventoryReference'.
*
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created.<br /><br /><span class=\"tablenote\"><b>Note:</b> You can retrieve the campaign IDs for a specified seller using the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a> method.</span> (required)
* @param string $inventory_reference_id The inventory reference ID associated with the ad you want returned. A seller's inventory reference ID is the ID of either a listing or the ID of an inventory item group (the parent of a multi-variation listing, such as a shirt that is available in multiple sizes and colors). You must always supply in both an <b>inventory_reference_id</b> and an <b>inventory_reference_type</b>. (required)
* @param string $inventory_reference_type The type of the inventory reference ID. Set this value to either <code>INVENTORY_ITEM</CODE> (a single listing) or <code>INVENTORY_ITEM_GROUP</CODE> (a multi-variation listing). You must always pass in both an <b>inventory_reference_id</b> and an <b>inventory_reference_type</b>. (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Psr7\Request
*/
public function getAdsByInventoryReferenceRequest($campaign_id, $inventory_reference_id, $inventory_reference_type)
{
// 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 getAdsByInventoryReference');
}
// Verify the required parameter 'inventory_reference_id' is set.
if ($inventory_reference_id === null || (\is_array($inventory_reference_id) && count($inventory_reference_id) === 0)) {
throw new \InvalidArgumentException('Missing the required parameter $inventory_reference_id when calling getAdsByInventoryReference');
}
// Verify the required parameter 'inventory_reference_type' is set.
if ($inventory_reference_type === null || (\is_array($inventory_reference_type) && count($inventory_reference_type) === 0)) {
throw new \InvalidArgumentException('Missing the required parameter $inventory_reference_type when calling getAdsByInventoryReference');
}
$resourcePath = '/ad_campaign/{campaign_id}/get_ads_by_inventory_reference';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
$inventory_reference_id,
'inventory_reference_id', // param base name
'string', // openApiType
'form', // style
true // explode
) ?? []);
// query params
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
$inventory_reference_type,
'inventory_reference_type', // param base name
'string', // openApiType
'form', // style
true // explode
) ?? []);
// path params
if ($campaign_id !== null) {
$resourcePath = str_replace(
'{campaign_id}',
ObjectSerializer::toPathValue($campaign_id),
$resourcePath
);
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// For model (json/xml)
if (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
foreach ($formParamValueItems as $formParamValueItem) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValueItem,
];
}
}
// For HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// For HTTP post (form)
$httpBody = ObjectSerializer::buildQuery($queryParams);
}
}
// this endpoint requires OAuth (access token)
if (! empty($this->config->getAccessToken())) {
$headers['Authorization'] = 'Bearer '.$this->config->getAccessToken();
}
// this endpoint requires OAuth (access token)
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 = ObjectSerializer::buildQuery($queryParams);
return new Request(
'GET',
$this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation updateBid.
*
* @param string $ad_id A unique eBay-assigned ID for an ad that's generated when an ad is created. (required)
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created.<br /><br /><span class=\"tablenote\"><b>Note:</b> You can retrieve the campaign IDs for a specified seller using the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a> method.</span> (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\UpdateBidPercentageRequest $update_bid_percentage_request This type defines the fields for the <b>updateBid</b> request. (required)
*
* @throws \TNT\Ebay\Sell\Marketing\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return void
*/
public function updateBid($ad_id, $campaign_id, $update_bid_percentage_request)
{
$this->updateBidWithHttpInfo($ad_id, $campaign_id, $update_bid_percentage_request);
}
/**
* Operation updateBidWithHttpInfo.
*
* @param string $ad_id A unique eBay-assigned ID for an ad that's generated when an ad is created. (required)
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created.<br /><br /><span class=\"tablenote\"><b>Note:</b> You can retrieve the campaign IDs for a specified seller using the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a> method.</span> (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\UpdateBidPercentageRequest $update_bid_percentage_request This type defines the fields for the <b>updateBid</b> request. (required)
*
* @throws \TNT\Ebay\Sell\Marketing\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return array of null, HTTP status code, HTTP response headers (array of strings)
*/
public function updateBidWithHttpInfo($ad_id, $campaign_id, $update_bid_percentage_request)
{
$request = $this->updateBidRequest($ad_id, $campaign_id, $update_bid_percentage_request);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null, $e);
} catch (ConnectException $e) {
throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), null, null, $e);
} catch (GuzzleException $e) {
throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), null, null, $e);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(sprintf('[%d] Error connecting to the API (%s)', $statusCode, (string) $request->getUri()), $statusCode, $response->getHeaders(), (string) $response->getBody());
}
return [null, $statusCode, $response->getHeaders()];
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
/**
* Operation updateBidAsync.
*
* @param string $ad_id A unique eBay-assigned ID for an ad that's generated when an ad is created. (required)
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created.<br /><br /><span class=\"tablenote\"><b>Note:</b> You can retrieve the campaign IDs for a specified seller using the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a> method.</span> (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\UpdateBidPercentageRequest $update_bid_percentage_request This type defines the fields for the <b>updateBid</b> request. (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateBidAsync($ad_id, $campaign_id, $update_bid_percentage_request)
{
return $this->updateBidAsyncWithHttpInfo($ad_id, $campaign_id, $update_bid_percentage_request)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation updateBidAsyncWithHttpInfo.
*
* @param string $ad_id A unique eBay-assigned ID for an ad that's generated when an ad is created. (required)
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created.<br /><br /><span class=\"tablenote\"><b>Note:</b> You can retrieve the campaign IDs for a specified seller using the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a> method.</span> (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\UpdateBidPercentageRequest $update_bid_percentage_request This type defines the fields for the <b>updateBid</b> request. (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateBidAsyncWithHttpInfo($ad_id, $campaign_id, $update_bid_percentage_request)
{
$returnType = '';
$request = $this->updateBidRequest($ad_id, $campaign_id, $update_bid_percentage_request);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) {
return [null, $response->getStatusCode(), $response->getHeaders()];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(sprintf('[%d] Error connecting to the API (%s)', $statusCode, $exception->getRequest()->getUri()), $statusCode, $response->getHeaders(), (string) $response->getBody(), $exception instanceof \Throwable ? $exception : null);
}
);
}
/**
* Create request for operation 'updateBid'.
*
* @param string $ad_id A unique eBay-assigned ID for an ad that's generated when an ad is created. (required)
* @param string $campaign_id A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created.<br /><br /><span class=\"tablenote\"><b>Note:</b> You can retrieve the campaign IDs for a specified seller using the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getCampaigns\">getCampaigns</a> method.</span> (required)
* @param \TNT\Ebay\Sell\Marketing\V1\Model\UpdateBidPercentageRequest $update_bid_percentage_request This type defines the fields for the <b>updateBid</b> request. (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Psr7\Request
*/
public function updateBidRequest($ad_id, $campaign_id, $update_bid_percentage_request)
{
// Verify the required parameter 'ad_id' is set.
if ($ad_id === null || (\is_array($ad_id) && count($ad_id) === 0)) {
throw new \InvalidArgumentException('Missing the required parameter $ad_id when calling updateBid');
}
// 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 updateBid');
}
// Verify the required parameter 'update_bid_percentage_request' is set.
if ($update_bid_percentage_request === null || (\is_array($update_bid_percentage_request) && count($update_bid_percentage_request) === 0)) {
throw new \InvalidArgumentException('Missing the required parameter $update_bid_percentage_request when calling updateBid');
}
$resourcePath = '/ad_campaign/{campaign_id}/ad/{ad_id}/update_bid';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// path params
if ($ad_id !== null) {
$resourcePath = str_replace(
'{ad_id}',
ObjectSerializer::toPathValue($ad_id),
$resourcePath
);
}
// path params
if ($campaign_id !== null) {
$resourcePath = str_replace(
'{campaign_id}',
ObjectSerializer::toPathValue($campaign_id),
$resourcePath
);
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
[]
);
} else {
$headers = $this->headerSelector->selectHeaders(
[],
['application/json']
);
}
// For model (json/xml)
if (isset($update_bid_percentage_request)) {
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($update_bid_percentage_request));
} else {
$httpBody = $update_bid_percentage_request;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
foreach ($formParamValueItems as $formParamValueItem) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValueItem,
];
}
}
// For HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// For HTTP post (form)
$httpBody = ObjectSerializer::buildQuery($queryParams);
}
}
// this endpoint requires OAuth (access token)
if (! empty($this->config->getAccessToken())) {
$headers['Authorization'] = 'Bearer '.$this->config->getAccessToken();
}
// this endpoint requires OAuth (access token)
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 = ObjectSerializer::buildQuery($queryParams);
return new Request(
'POST',
$this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Create http client option.
*
* @throws \RuntimeException on file opening failure
*
* @return array of http client options
*/
protected function createHttpClientOption()
{
$options = [];
if ($this->config->getDebug()) {
$options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'ab');
if (! $options[RequestOptions::DEBUG]) {
throw new \RuntimeException('Failed to open the debug file: '.$this->config->getDebugFile());
}
}
return $options;
}
}