src/Sell/Account/V1/Api/LocationApi.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);
/**
* LocationApi.
*
* PHP version ^7.2 || ^8.0
*
* @category Class
*
* @author OpenAPI Generator team
*
* @see https://openapi-generator.tech
*/
/**
* Account API.
*
* The <b>Account API</b> gives sellers the ability to configure their eBay seller accounts, including the seller's policies (eBay business policies and seller-defined custom policies), opt in and out of eBay seller programs, configure sales tax tables, and get account information. <br/><br/>For details on the availability of the methods in this API, see <a href=\"/api-docs/sell/account/overview.html#requirements\">Account API requirements and restrictions</a>.
*
* The version of the OpenAPI document: v1.9.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\Account\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\Account\V1\ApiException;
use TNT\Ebay\Sell\Account\V1\Configuration;
use TNT\Ebay\Sell\Account\V1\HeaderSelector;
use TNT\Ebay\Sell\Account\V1\ObjectSerializer;
/**
* LocationApi Class Doc Comment.
*
* @category Class
*
* @author OpenAPI Generator team
*
* @see https://openapi-generator.tech
*/
class LocationApi
{
/**
* @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 createInventoryLocation.
*
* This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host.
* URL: https://api.ebay.com{basePath}
*
* @param string $merchant_location_key A unique, merchant-defined key (ID) for an inventory location. This unique identifier, or key, is used in other Inventory API calls to identify an inventory location. <br/><br/><b>Max length</b>: 36 (required)
* @param \TNT\Ebay\Sell\Account\V1\Model\InventoryLocationFull $inventory_location_full Inventory Location details (required)
*
* @throws \TNT\Ebay\Sell\Account\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return void
*/
public function createInventoryLocation($merchant_location_key, $inventory_location_full)
{
$this->createInventoryLocationWithHttpInfo($merchant_location_key, $inventory_location_full);
}
/**
* Operation createInventoryLocationWithHttpInfo.
*
* This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host.
* URL: https://api.ebay.com{basePath}
*
* @param string $merchant_location_key A unique, merchant-defined key (ID) for an inventory location. This unique identifier, or key, is used in other Inventory API calls to identify an inventory location. <br/><br/><b>Max length</b>: 36 (required)
* @param \TNT\Ebay\Sell\Account\V1\Model\InventoryLocationFull $inventory_location_full Inventory Location details (required)
*
* @throws \TNT\Ebay\Sell\Account\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return array of null, HTTP status code, HTTP response headers (array of strings)
*/
public function createInventoryLocationWithHttpInfo($merchant_location_key, $inventory_location_full)
{
$request = $this->createInventoryLocationRequest($merchant_location_key, $inventory_location_full);
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 createInventoryLocationAsync.
*
* This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host.
* URL: https://api.ebay.com{basePath}
*
* @param string $merchant_location_key A unique, merchant-defined key (ID) for an inventory location. This unique identifier, or key, is used in other Inventory API calls to identify an inventory location. <br/><br/><b>Max length</b>: 36 (required)
* @param \TNT\Ebay\Sell\Account\V1\Model\InventoryLocationFull $inventory_location_full Inventory Location details (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createInventoryLocationAsync($merchant_location_key, $inventory_location_full)
{
return $this->createInventoryLocationAsyncWithHttpInfo($merchant_location_key, $inventory_location_full)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createInventoryLocationAsyncWithHttpInfo.
*
* This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host.
* URL: https://api.ebay.com{basePath}
*
* @param string $merchant_location_key A unique, merchant-defined key (ID) for an inventory location. This unique identifier, or key, is used in other Inventory API calls to identify an inventory location. <br/><br/><b>Max length</b>: 36 (required)
* @param \TNT\Ebay\Sell\Account\V1\Model\InventoryLocationFull $inventory_location_full Inventory Location details (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createInventoryLocationAsyncWithHttpInfo($merchant_location_key, $inventory_location_full)
{
$returnType = '';
$request = $this->createInventoryLocationRequest($merchant_location_key, $inventory_location_full);
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 'createInventoryLocation'.
*
* This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host.
* URL: https://api.ebay.com{basePath}
*
* @param string $merchant_location_key A unique, merchant-defined key (ID) for an inventory location. This unique identifier, or key, is used in other Inventory API calls to identify an inventory location. <br/><br/><b>Max length</b>: 36 (required)
* @param \TNT\Ebay\Sell\Account\V1\Model\InventoryLocationFull $inventory_location_full Inventory Location details (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Psr7\Request
*/
public function createInventoryLocationRequest($merchant_location_key, $inventory_location_full)
{
// Verify the required parameter 'merchant_location_key' is set.
if ($merchant_location_key === null || (\is_array($merchant_location_key) && count($merchant_location_key) === 0)) {
throw new \InvalidArgumentException('Missing the required parameter $merchant_location_key when calling createInventoryLocation');
}
// Verify the required parameter 'inventory_location_full' is set.
if ($inventory_location_full === null || (\is_array($inventory_location_full) && count($inventory_location_full) === 0)) {
throw new \InvalidArgumentException('Missing the required parameter $inventory_location_full when calling createInventoryLocation');
}
$resourcePath = '/location/{merchantLocationKey}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// path params
if ($merchant_location_key !== null) {
$resourcePath = str_replace(
'{merchantLocationKey}',
ObjectSerializer::toPathValue($merchant_location_key),
$resourcePath
);
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
[]
);
} else {
$headers = $this->headerSelector->selectHeaders(
[],
['application/json']
);
}
// For model (json/xml)
if (isset($inventory_location_full)) {
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($inventory_location_full));
} else {
$httpBody = $inventory_location_full;
}
} 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
);
$operationHosts = ['https://api.ebay.com{basePath}'];
if ($this->hostIndex < 0 || $this->hostIndex >= count($operationHosts)) {
throw new \InvalidArgumentException("Invalid index {$this->hostIndex} when selecting the host. Must be less than ".count($operationHosts));
}
$operationHost = $operationHosts[$this->hostIndex];
$query = ObjectSerializer::buildQuery($queryParams);
return new Request(
'POST',
$operationHost.$resourcePath.($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation deleteInventoryLocation.
*
* This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host.
* URL: https://api.ebay.com{basePath}
*
* @param string $merchant_location_key A unique merchant-defined key (ID) for an inventory location. This value is passed in at the end of the call URI to indicate the inventory location to be deleted. <br/><br/><b>Max length</b>: 36 (required)
*
* @throws \TNT\Ebay\Sell\Account\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return void
*/
public function deleteInventoryLocation($merchant_location_key)
{
$this->deleteInventoryLocationWithHttpInfo($merchant_location_key);
}
/**
* Operation deleteInventoryLocationWithHttpInfo.
*
* This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host.
* URL: https://api.ebay.com{basePath}
*
* @param string $merchant_location_key A unique merchant-defined key (ID) for an inventory location. This value is passed in at the end of the call URI to indicate the inventory location to be deleted. <br/><br/><b>Max length</b>: 36 (required)
*
* @throws \TNT\Ebay\Sell\Account\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return array of null, HTTP status code, HTTP response headers (array of strings)
*/
public function deleteInventoryLocationWithHttpInfo($merchant_location_key)
{
$request = $this->deleteInventoryLocationRequest($merchant_location_key);
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 deleteInventoryLocationAsync.
*
* This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host.
* URL: https://api.ebay.com{basePath}
*
* @param string $merchant_location_key A unique merchant-defined key (ID) for an inventory location. This value is passed in at the end of the call URI to indicate the inventory location to be deleted. <br/><br/><b>Max length</b>: 36 (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function deleteInventoryLocationAsync($merchant_location_key)
{
return $this->deleteInventoryLocationAsyncWithHttpInfo($merchant_location_key)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation deleteInventoryLocationAsyncWithHttpInfo.
*
* This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host.
* URL: https://api.ebay.com{basePath}
*
* @param string $merchant_location_key A unique merchant-defined key (ID) for an inventory location. This value is passed in at the end of the call URI to indicate the inventory location to be deleted. <br/><br/><b>Max length</b>: 36 (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function deleteInventoryLocationAsyncWithHttpInfo($merchant_location_key)
{
$returnType = '';
$request = $this->deleteInventoryLocationRequest($merchant_location_key);
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 'deleteInventoryLocation'.
*
* This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host.
* URL: https://api.ebay.com{basePath}
*
* @param string $merchant_location_key A unique merchant-defined key (ID) for an inventory location. This value is passed in at the end of the call URI to indicate the inventory location to be deleted. <br/><br/><b>Max length</b>: 36 (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Psr7\Request
*/
public function deleteInventoryLocationRequest($merchant_location_key)
{
// Verify the required parameter 'merchant_location_key' is set.
if ($merchant_location_key === null || (\is_array($merchant_location_key) && count($merchant_location_key) === 0)) {
throw new \InvalidArgumentException('Missing the required parameter $merchant_location_key when calling deleteInventoryLocation');
}
$resourcePath = '/location/{merchantLocationKey}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// path params
if ($merchant_location_key !== null) {
$resourcePath = str_replace(
'{merchantLocationKey}',
ObjectSerializer::toPathValue($merchant_location_key),
$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
);
$operationHosts = ['https://api.ebay.com{basePath}'];
if ($this->hostIndex < 0 || $this->hostIndex >= count($operationHosts)) {
throw new \InvalidArgumentException("Invalid index {$this->hostIndex} when selecting the host. Must be less than ".count($operationHosts));
}
$operationHost = $operationHosts[$this->hostIndex];
$query = ObjectSerializer::buildQuery($queryParams);
return new Request(
'DELETE',
$operationHost.$resourcePath.($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation disableInventoryLocation.
*
* This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host.
* URL: https://api.ebay.com{basePath}
*
* @param string $merchant_location_key A unique merchant-defined key (ID) for an inventory location. This value is passed in through the call URI to disable the specified inventory location. <br/><br/><b>Max length</b>: 36 (required)
*
* @throws \TNT\Ebay\Sell\Account\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return object
*/
public function disableInventoryLocation($merchant_location_key)
{
[$response] = $this->disableInventoryLocationWithHttpInfo($merchant_location_key);
return $response;
}
/**
* Operation disableInventoryLocationWithHttpInfo.
*
* This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host.
* URL: https://api.ebay.com{basePath}
*
* @param string $merchant_location_key A unique merchant-defined key (ID) for an inventory location. This value is passed in through the call URI to disable the specified inventory location. <br/><br/><b>Max length</b>: 36 (required)
*
* @throws \TNT\Ebay\Sell\Account\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return array of object, HTTP status code, HTTP response headers (array of strings)
*/
public function disableInventoryLocationWithHttpInfo($merchant_location_key)
{
$request = $this->disableInventoryLocationRequest($merchant_location_key);
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 ('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 200:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'object',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation disableInventoryLocationAsync.
*
* This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host.
* URL: https://api.ebay.com{basePath}
*
* @param string $merchant_location_key A unique merchant-defined key (ID) for an inventory location. This value is passed in through the call URI to disable the specified inventory location. <br/><br/><b>Max length</b>: 36 (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function disableInventoryLocationAsync($merchant_location_key)
{
return $this->disableInventoryLocationAsyncWithHttpInfo($merchant_location_key)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation disableInventoryLocationAsyncWithHttpInfo.
*
* This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host.
* URL: https://api.ebay.com{basePath}
*
* @param string $merchant_location_key A unique merchant-defined key (ID) for an inventory location. This value is passed in through the call URI to disable the specified inventory location. <br/><br/><b>Max length</b>: 36 (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function disableInventoryLocationAsyncWithHttpInfo($merchant_location_key)
{
$returnType = 'object';
$request = $this->disableInventoryLocationRequest($merchant_location_key);
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 'disableInventoryLocation'.
*
* This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host.
* URL: https://api.ebay.com{basePath}
*
* @param string $merchant_location_key A unique merchant-defined key (ID) for an inventory location. This value is passed in through the call URI to disable the specified inventory location. <br/><br/><b>Max length</b>: 36 (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Psr7\Request
*/
public function disableInventoryLocationRequest($merchant_location_key)
{
// Verify the required parameter 'merchant_location_key' is set.
if ($merchant_location_key === null || (\is_array($merchant_location_key) && count($merchant_location_key) === 0)) {
throw new \InvalidArgumentException('Missing the required parameter $merchant_location_key when calling disableInventoryLocation');
}
$resourcePath = '/location/{merchantLocationKey}/disable';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// path params
if ($merchant_location_key !== null) {
$resourcePath = str_replace(
'{merchantLocationKey}',
ObjectSerializer::toPathValue($merchant_location_key),
$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
);
$operationHosts = ['https://api.ebay.com{basePath}'];
if ($this->hostIndex < 0 || $this->hostIndex >= count($operationHosts)) {
throw new \InvalidArgumentException("Invalid index {$this->hostIndex} when selecting the host. Must be less than ".count($operationHosts));
}
$operationHost = $operationHosts[$this->hostIndex];
$query = ObjectSerializer::buildQuery($queryParams);
return new Request(
'POST',
$operationHost.$resourcePath.($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation enableInventoryLocation.
*
* This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host.
* URL: https://api.ebay.com{basePath}
*
* @param string $merchant_location_key A unique merchant-defined key (ID) for an inventory location. This value is passed in through the call URI to specify the disabled inventory location to enable. <br/><br/><b>Max length</b>: 36 (required)
*
* @throws \TNT\Ebay\Sell\Account\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return object
*/
public function enableInventoryLocation($merchant_location_key)
{
[$response] = $this->enableInventoryLocationWithHttpInfo($merchant_location_key);
return $response;
}
/**
* Operation enableInventoryLocationWithHttpInfo.
*
* This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host.
* URL: https://api.ebay.com{basePath}
*
* @param string $merchant_location_key A unique merchant-defined key (ID) for an inventory location. This value is passed in through the call URI to specify the disabled inventory location to enable. <br/><br/><b>Max length</b>: 36 (required)
*
* @throws \TNT\Ebay\Sell\Account\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return array of object, HTTP status code, HTTP response headers (array of strings)
*/
public function enableInventoryLocationWithHttpInfo($merchant_location_key)
{
$request = $this->enableInventoryLocationRequest($merchant_location_key);
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 ('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 200:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'object',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation enableInventoryLocationAsync.
*
* This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host.
* URL: https://api.ebay.com{basePath}
*
* @param string $merchant_location_key A unique merchant-defined key (ID) for an inventory location. This value is passed in through the call URI to specify the disabled inventory location to enable. <br/><br/><b>Max length</b>: 36 (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function enableInventoryLocationAsync($merchant_location_key)
{
return $this->enableInventoryLocationAsyncWithHttpInfo($merchant_location_key)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation enableInventoryLocationAsyncWithHttpInfo.
*
* This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host.
* URL: https://api.ebay.com{basePath}
*
* @param string $merchant_location_key A unique merchant-defined key (ID) for an inventory location. This value is passed in through the call URI to specify the disabled inventory location to enable. <br/><br/><b>Max length</b>: 36 (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function enableInventoryLocationAsyncWithHttpInfo($merchant_location_key)
{
$returnType = 'object';
$request = $this->enableInventoryLocationRequest($merchant_location_key);
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 'enableInventoryLocation'.
*
* This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host.
* URL: https://api.ebay.com{basePath}
*
* @param string $merchant_location_key A unique merchant-defined key (ID) for an inventory location. This value is passed in through the call URI to specify the disabled inventory location to enable. <br/><br/><b>Max length</b>: 36 (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Psr7\Request
*/
public function enableInventoryLocationRequest($merchant_location_key)
{
// Verify the required parameter 'merchant_location_key' is set.
if ($merchant_location_key === null || (\is_array($merchant_location_key) && count($merchant_location_key) === 0)) {
throw new \InvalidArgumentException('Missing the required parameter $merchant_location_key when calling enableInventoryLocation');
}
$resourcePath = '/location/{merchantLocationKey}/enable';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// path params
if ($merchant_location_key !== null) {
$resourcePath = str_replace(
'{merchantLocationKey}',
ObjectSerializer::toPathValue($merchant_location_key),
$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
);
$operationHosts = ['https://api.ebay.com{basePath}'];
if ($this->hostIndex < 0 || $this->hostIndex >= count($operationHosts)) {
throw new \InvalidArgumentException("Invalid index {$this->hostIndex} when selecting the host. Must be less than ".count($operationHosts));
}
$operationHost = $operationHosts[$this->hostIndex];
$query = ObjectSerializer::buildQuery($queryParams);
return new Request(
'POST',
$operationHost.$resourcePath.($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getInventoryLocation.
*
* This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host.
* URL: https://api.ebay.com{basePath}
*
* @param string $merchant_location_key A unique merchant-defined key (ID) for an inventory location. This value is passed in at the end of the call URI to specify the inventory location to retrieve. <br/><br/><b>Max length</b>: 36 (required)
*
* @throws \TNT\Ebay\Sell\Account\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return \TNT\Ebay\Sell\Account\V1\Model\InventoryLocationResponse
*/
public function getInventoryLocation($merchant_location_key)
{
[$response] = $this->getInventoryLocationWithHttpInfo($merchant_location_key);
return $response;
}
/**
* Operation getInventoryLocationWithHttpInfo.
*
* This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host.
* URL: https://api.ebay.com{basePath}
*
* @param string $merchant_location_key A unique merchant-defined key (ID) for an inventory location. This value is passed in at the end of the call URI to specify the inventory location to retrieve. <br/><br/><b>Max length</b>: 36 (required)
*
* @throws \TNT\Ebay\Sell\Account\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return array of \TNT\Ebay\Sell\Account\V1\Model\InventoryLocationResponse, HTTP status code, HTTP response headers (array of strings)
*/
public function getInventoryLocationWithHttpInfo($merchant_location_key)
{
$request = $this->getInventoryLocationRequest($merchant_location_key);
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\Account\V1\Model\InventoryLocationResponse' === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, '\TNT\Ebay\Sell\Account\V1\Model\InventoryLocationResponse', []),
$response->getStatusCode(),
$response->getHeaders(),
];
}
$returnType = '\TNT\Ebay\Sell\Account\V1\Model\InventoryLocationResponse';
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\Account\V1\Model\InventoryLocationResponse',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getInventoryLocationAsync.
*
* This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host.
* URL: https://api.ebay.com{basePath}
*
* @param string $merchant_location_key A unique merchant-defined key (ID) for an inventory location. This value is passed in at the end of the call URI to specify the inventory location to retrieve. <br/><br/><b>Max length</b>: 36 (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getInventoryLocationAsync($merchant_location_key)
{
return $this->getInventoryLocationAsyncWithHttpInfo($merchant_location_key)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getInventoryLocationAsyncWithHttpInfo.
*
* This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host.
* URL: https://api.ebay.com{basePath}
*
* @param string $merchant_location_key A unique merchant-defined key (ID) for an inventory location. This value is passed in at the end of the call URI to specify the inventory location to retrieve. <br/><br/><b>Max length</b>: 36 (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getInventoryLocationAsyncWithHttpInfo($merchant_location_key)
{
$returnType = '\TNT\Ebay\Sell\Account\V1\Model\InventoryLocationResponse';
$request = $this->getInventoryLocationRequest($merchant_location_key);
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 'getInventoryLocation'.
*
* This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host.
* URL: https://api.ebay.com{basePath}
*
* @param string $merchant_location_key A unique merchant-defined key (ID) for an inventory location. This value is passed in at the end of the call URI to specify the inventory location to retrieve. <br/><br/><b>Max length</b>: 36 (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Psr7\Request
*/
public function getInventoryLocationRequest($merchant_location_key)
{
// Verify the required parameter 'merchant_location_key' is set.
if ($merchant_location_key === null || (\is_array($merchant_location_key) && count($merchant_location_key) === 0)) {
throw new \InvalidArgumentException('Missing the required parameter $merchant_location_key when calling getInventoryLocation');
}
$resourcePath = '/location/{merchantLocationKey}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// path params
if ($merchant_location_key !== null) {
$resourcePath = str_replace(
'{merchantLocationKey}',
ObjectSerializer::toPathValue($merchant_location_key),
$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
);
$operationHosts = ['https://api.ebay.com{basePath}'];
if ($this->hostIndex < 0 || $this->hostIndex >= count($operationHosts)) {
throw new \InvalidArgumentException("Invalid index {$this->hostIndex} when selecting the host. Must be less than ".count($operationHosts));
}
$operationHost = $operationHosts[$this->hostIndex];
$query = ObjectSerializer::buildQuery($queryParams);
return new Request(
'GET',
$operationHost.$resourcePath.($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getInventoryLocations.
*
* This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host.
* URL: https://api.ebay.com{basePath}
*
* @param string $limit The value passed in this query parameter sets the maximum number of records to return per page of data. Although this field is a string, the value passed in this field should be a positive integer value. If this query parameter is not set, up to 100 records will be returned on each page of results. <br/><br/> <strong>Min</strong>: 1 (optional)
* @param string $offset Specifies the number of locations to skip in the result set before returning the first location 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\Account\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return \TNT\Ebay\Sell\Account\V1\Model\LocationResponse
*/
public function getInventoryLocations($limit = null, $offset = null)
{
[$response] = $this->getInventoryLocationsWithHttpInfo($limit, $offset);
return $response;
}
/**
* Operation getInventoryLocationsWithHttpInfo.
*
* This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host.
* URL: https://api.ebay.com{basePath}
*
* @param string $limit The value passed in this query parameter sets the maximum number of records to return per page of data. Although this field is a string, the value passed in this field should be a positive integer value. If this query parameter is not set, up to 100 records will be returned on each page of results. <br/><br/> <strong>Min</strong>: 1 (optional)
* @param string $offset Specifies the number of locations to skip in the result set before returning the first location 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\Account\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return array of \TNT\Ebay\Sell\Account\V1\Model\LocationResponse, HTTP status code, HTTP response headers (array of strings)
*/
public function getInventoryLocationsWithHttpInfo($limit = null, $offset = null)
{
$request = $this->getInventoryLocationsRequest($limit, $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\Account\V1\Model\LocationResponse' === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, '\TNT\Ebay\Sell\Account\V1\Model\LocationResponse', []),
$response->getStatusCode(),
$response->getHeaders(),
];
}
$returnType = '\TNT\Ebay\Sell\Account\V1\Model\LocationResponse';
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\Account\V1\Model\LocationResponse',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getInventoryLocationsAsync.
*
* This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host.
* URL: https://api.ebay.com{basePath}
*
* @param string $limit The value passed in this query parameter sets the maximum number of records to return per page of data. Although this field is a string, the value passed in this field should be a positive integer value. If this query parameter is not set, up to 100 records will be returned on each page of results. <br/><br/> <strong>Min</strong>: 1 (optional)
* @param string $offset Specifies the number of locations to skip in the result set before returning the first location 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 getInventoryLocationsAsync($limit = null, $offset = null)
{
return $this->getInventoryLocationsAsyncWithHttpInfo($limit, $offset)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getInventoryLocationsAsyncWithHttpInfo.
*
* This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host.
* URL: https://api.ebay.com{basePath}
*
* @param string $limit The value passed in this query parameter sets the maximum number of records to return per page of data. Although this field is a string, the value passed in this field should be a positive integer value. If this query parameter is not set, up to 100 records will be returned on each page of results. <br/><br/> <strong>Min</strong>: 1 (optional)
* @param string $offset Specifies the number of locations to skip in the result set before returning the first location 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 getInventoryLocationsAsyncWithHttpInfo($limit = null, $offset = null)
{
$returnType = '\TNT\Ebay\Sell\Account\V1\Model\LocationResponse';
$request = $this->getInventoryLocationsRequest($limit, $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 'getInventoryLocations'.
*
* This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host.
* URL: https://api.ebay.com{basePath}
*
* @param string $limit The value passed in this query parameter sets the maximum number of records to return per page of data. Although this field is a string, the value passed in this field should be a positive integer value. If this query parameter is not set, up to 100 records will be returned on each page of results. <br/><br/> <strong>Min</strong>: 1 (optional)
* @param string $offset Specifies the number of locations to skip in the result set before returning the first location 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 getInventoryLocationsRequest($limit = null, $offset = null)
{
$resourcePath = '/location';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// 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(
$offset,
'offset', // param base name
'string', // openApiType
'form', // style
true // explode
) ?? []);
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
);
$operationHosts = ['https://api.ebay.com{basePath}'];
if ($this->hostIndex < 0 || $this->hostIndex >= count($operationHosts)) {
throw new \InvalidArgumentException("Invalid index {$this->hostIndex} when selecting the host. Must be less than ".count($operationHosts));
}
$operationHost = $operationHosts[$this->hostIndex];
$query = ObjectSerializer::buildQuery($queryParams);
return new Request(
'GET',
$operationHost.$resourcePath.($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation updateInventoryLocation.
*
* This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host.
* URL: https://api.ebay.com{basePath}
*
* @param string $merchant_location_key A unique merchant-defined key (ID) for an inventory location. This value is passed in the call URI to indicate the inventory location to be updated. <br/><br/><b>Max length</b>: 36 (required)
* @param \TNT\Ebay\Sell\Account\V1\Model\InventoryLocation $inventory_location The inventory location details to be updated (other than the address and geo co-ordinates). (required)
*
* @throws \TNT\Ebay\Sell\Account\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return void
*/
public function updateInventoryLocation($merchant_location_key, $inventory_location)
{
$this->updateInventoryLocationWithHttpInfo($merchant_location_key, $inventory_location);
}
/**
* Operation updateInventoryLocationWithHttpInfo.
*
* This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host.
* URL: https://api.ebay.com{basePath}
*
* @param string $merchant_location_key A unique merchant-defined key (ID) for an inventory location. This value is passed in the call URI to indicate the inventory location to be updated. <br/><br/><b>Max length</b>: 36 (required)
* @param \TNT\Ebay\Sell\Account\V1\Model\InventoryLocation $inventory_location The inventory location details to be updated (other than the address and geo co-ordinates). (required)
*
* @throws \TNT\Ebay\Sell\Account\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return array of null, HTTP status code, HTTP response headers (array of strings)
*/
public function updateInventoryLocationWithHttpInfo($merchant_location_key, $inventory_location)
{
$request = $this->updateInventoryLocationRequest($merchant_location_key, $inventory_location);
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 updateInventoryLocationAsync.
*
* This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host.
* URL: https://api.ebay.com{basePath}
*
* @param string $merchant_location_key A unique merchant-defined key (ID) for an inventory location. This value is passed in the call URI to indicate the inventory location to be updated. <br/><br/><b>Max length</b>: 36 (required)
* @param \TNT\Ebay\Sell\Account\V1\Model\InventoryLocation $inventory_location The inventory location details to be updated (other than the address and geo co-ordinates). (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateInventoryLocationAsync($merchant_location_key, $inventory_location)
{
return $this->updateInventoryLocationAsyncWithHttpInfo($merchant_location_key, $inventory_location)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation updateInventoryLocationAsyncWithHttpInfo.
*
* This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host.
* URL: https://api.ebay.com{basePath}
*
* @param string $merchant_location_key A unique merchant-defined key (ID) for an inventory location. This value is passed in the call URI to indicate the inventory location to be updated. <br/><br/><b>Max length</b>: 36 (required)
* @param \TNT\Ebay\Sell\Account\V1\Model\InventoryLocation $inventory_location The inventory location details to be updated (other than the address and geo co-ordinates). (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateInventoryLocationAsyncWithHttpInfo($merchant_location_key, $inventory_location)
{
$returnType = '';
$request = $this->updateInventoryLocationRequest($merchant_location_key, $inventory_location);
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 'updateInventoryLocation'.
*
* This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host.
* URL: https://api.ebay.com{basePath}
*
* @param string $merchant_location_key A unique merchant-defined key (ID) for an inventory location. This value is passed in the call URI to indicate the inventory location to be updated. <br/><br/><b>Max length</b>: 36 (required)
* @param \TNT\Ebay\Sell\Account\V1\Model\InventoryLocation $inventory_location The inventory location details to be updated (other than the address and geo co-ordinates). (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Psr7\Request
*/
public function updateInventoryLocationRequest($merchant_location_key, $inventory_location)
{
// Verify the required parameter 'merchant_location_key' is set.
if ($merchant_location_key === null || (\is_array($merchant_location_key) && count($merchant_location_key) === 0)) {
throw new \InvalidArgumentException('Missing the required parameter $merchant_location_key when calling updateInventoryLocation');
}
// Verify the required parameter 'inventory_location' is set.
if ($inventory_location === null || (\is_array($inventory_location) && count($inventory_location) === 0)) {
throw new \InvalidArgumentException('Missing the required parameter $inventory_location when calling updateInventoryLocation');
}
$resourcePath = '/location/{merchantLocationKey}/update_location_details';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// path params
if ($merchant_location_key !== null) {
$resourcePath = str_replace(
'{merchantLocationKey}',
ObjectSerializer::toPathValue($merchant_location_key),
$resourcePath
);
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
[]
);
} else {
$headers = $this->headerSelector->selectHeaders(
[],
['application/json']
);
}
// For model (json/xml)
if (isset($inventory_location)) {
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($inventory_location));
} else {
$httpBody = $inventory_location;
}
} 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
);
$operationHosts = ['https://api.ebay.com{basePath}'];
if ($this->hostIndex < 0 || $this->hostIndex >= count($operationHosts)) {
throw new \InvalidArgumentException("Invalid index {$this->hostIndex} when selecting the host. Must be less than ".count($operationHosts));
}
$operationHost = $operationHosts[$this->hostIndex];
$query = ObjectSerializer::buildQuery($queryParams);
return new Request(
'POST',
$operationHost.$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;
}
}