src/Sell/Account/V1/Api/PaymentPolicyApi.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);
/**
* PaymentPolicyApi.
*
* 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;
/**
* PaymentPolicyApi Class Doc Comment.
*
* @category Class
*
* @author OpenAPI Generator team
*
* @see https://openapi-generator.tech
*/
class PaymentPolicyApi
{
/**
* @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 createPaymentPolicy.
*
* @param \TNT\Ebay\Sell\Account\V1\Model\PaymentPolicyRequest $payment_policy_request Payment policy request (required)
*
* @throws \TNT\Ebay\Sell\Account\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return \TNT\Ebay\Sell\Account\V1\Model\SetPaymentPolicyResponse
*/
public function createPaymentPolicy($payment_policy_request)
{
[$response] = $this->createPaymentPolicyWithHttpInfo($payment_policy_request);
return $response;
}
/**
* Operation createPaymentPolicyWithHttpInfo.
*
* @param \TNT\Ebay\Sell\Account\V1\Model\PaymentPolicyRequest $payment_policy_request Payment policy request (required)
*
* @throws \TNT\Ebay\Sell\Account\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return array of \TNT\Ebay\Sell\Account\V1\Model\SetPaymentPolicyResponse, HTTP status code, HTTP response headers (array of strings)
*/
public function createPaymentPolicyWithHttpInfo($payment_policy_request)
{
$request = $this->createPaymentPolicyRequest($payment_policy_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\Account\V1\Model\SetPaymentPolicyResponse' === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, '\TNT\Ebay\Sell\Account\V1\Model\SetPaymentPolicyResponse', []),
$response->getStatusCode(),
$response->getHeaders(),
];
}
$returnType = '\TNT\Ebay\Sell\Account\V1\Model\SetPaymentPolicyResponse';
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\Account\V1\Model\SetPaymentPolicyResponse',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createPaymentPolicyAsync.
*
* @param \TNT\Ebay\Sell\Account\V1\Model\PaymentPolicyRequest $payment_policy_request Payment policy request (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createPaymentPolicyAsync($payment_policy_request)
{
return $this->createPaymentPolicyAsyncWithHttpInfo($payment_policy_request)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createPaymentPolicyAsyncWithHttpInfo.
*
* @param \TNT\Ebay\Sell\Account\V1\Model\PaymentPolicyRequest $payment_policy_request Payment policy request (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createPaymentPolicyAsyncWithHttpInfo($payment_policy_request)
{
$returnType = '\TNT\Ebay\Sell\Account\V1\Model\SetPaymentPolicyResponse';
$request = $this->createPaymentPolicyRequest($payment_policy_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 'createPaymentPolicy'.
*
* @param \TNT\Ebay\Sell\Account\V1\Model\PaymentPolicyRequest $payment_policy_request Payment policy request (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Psr7\Request
*/
public function createPaymentPolicyRequest($payment_policy_request)
{
// Verify the required parameter 'payment_policy_request' is set.
if ($payment_policy_request === null || (\is_array($payment_policy_request) && count($payment_policy_request) === 0)) {
throw new \InvalidArgumentException('Missing the required parameter $payment_policy_request when calling createPaymentPolicy');
}
$resourcePath = '/payment_policy';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// For model (json/xml)
if (isset($payment_policy_request)) {
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($payment_policy_request));
} else {
$httpBody = $payment_policy_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 deletePaymentPolicy.
*
* @param string $payment_policy_id This path parameter specifies the ID of the payment policy you want to delete. (required)
*
* @throws \TNT\Ebay\Sell\Account\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return void
*/
public function deletePaymentPolicy($payment_policy_id)
{
$this->deletePaymentPolicyWithHttpInfo($payment_policy_id);
}
/**
* Operation deletePaymentPolicyWithHttpInfo.
*
* @param string $payment_policy_id This path parameter specifies the ID of the payment policy you want to delete. (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 deletePaymentPolicyWithHttpInfo($payment_policy_id)
{
$request = $this->deletePaymentPolicyRequest($payment_policy_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 deletePaymentPolicyAsync.
*
* @param string $payment_policy_id This path parameter specifies the ID of the payment policy you want to delete. (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function deletePaymentPolicyAsync($payment_policy_id)
{
return $this->deletePaymentPolicyAsyncWithHttpInfo($payment_policy_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation deletePaymentPolicyAsyncWithHttpInfo.
*
* @param string $payment_policy_id This path parameter specifies the ID of the payment policy you want to delete. (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function deletePaymentPolicyAsyncWithHttpInfo($payment_policy_id)
{
$returnType = '';
$request = $this->deletePaymentPolicyRequest($payment_policy_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 'deletePaymentPolicy'.
*
* @param string $payment_policy_id This path parameter specifies the ID of the payment policy you want to delete. (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Psr7\Request
*/
public function deletePaymentPolicyRequest($payment_policy_id)
{
// Verify the required parameter 'payment_policy_id' is set.
if ($payment_policy_id === null || (\is_array($payment_policy_id) && count($payment_policy_id) === 0)) {
throw new \InvalidArgumentException('Missing the required parameter $payment_policy_id when calling deletePaymentPolicy');
}
$resourcePath = '/payment_policy/{payment_policy_id}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// path params
if ($payment_policy_id !== null) {
$resourcePath = str_replace(
'{payment_policy_id}',
ObjectSerializer::toPathValue($payment_policy_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 getPaymentPolicies.
*
* @param string $marketplace_id This query parameter specifies the eBay marketplace of the policies you want to retrieve. For implementation help, refer to eBay API documentation at https://developer.ebay.com/api-docs/sell/account/types/ba:MarketplaceIdEnum (required)
*
* @throws \TNT\Ebay\Sell\Account\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return \TNT\Ebay\Sell\Account\V1\Model\PaymentPolicyResponse
*/
public function getPaymentPolicies($marketplace_id)
{
[$response] = $this->getPaymentPoliciesWithHttpInfo($marketplace_id);
return $response;
}
/**
* Operation getPaymentPoliciesWithHttpInfo.
*
* @param string $marketplace_id This query parameter specifies the eBay marketplace of the policies you want to retrieve. For implementation help, refer to eBay API documentation at https://developer.ebay.com/api-docs/sell/account/types/ba:MarketplaceIdEnum (required)
*
* @throws \TNT\Ebay\Sell\Account\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return array of \TNT\Ebay\Sell\Account\V1\Model\PaymentPolicyResponse, HTTP status code, HTTP response headers (array of strings)
*/
public function getPaymentPoliciesWithHttpInfo($marketplace_id)
{
$request = $this->getPaymentPoliciesRequest($marketplace_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\Account\V1\Model\PaymentPolicyResponse' === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, '\TNT\Ebay\Sell\Account\V1\Model\PaymentPolicyResponse', []),
$response->getStatusCode(),
$response->getHeaders(),
];
}
$returnType = '\TNT\Ebay\Sell\Account\V1\Model\PaymentPolicyResponse';
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\PaymentPolicyResponse',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getPaymentPoliciesAsync.
*
* @param string $marketplace_id This query parameter specifies the eBay marketplace of the policies you want to retrieve. For implementation help, refer to eBay API documentation at https://developer.ebay.com/api-docs/sell/account/types/ba:MarketplaceIdEnum (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getPaymentPoliciesAsync($marketplace_id)
{
return $this->getPaymentPoliciesAsyncWithHttpInfo($marketplace_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getPaymentPoliciesAsyncWithHttpInfo.
*
* @param string $marketplace_id This query parameter specifies the eBay marketplace of the policies you want to retrieve. For implementation help, refer to eBay API documentation at https://developer.ebay.com/api-docs/sell/account/types/ba:MarketplaceIdEnum (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getPaymentPoliciesAsyncWithHttpInfo($marketplace_id)
{
$returnType = '\TNT\Ebay\Sell\Account\V1\Model\PaymentPolicyResponse';
$request = $this->getPaymentPoliciesRequest($marketplace_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 'getPaymentPolicies'.
*
* @param string $marketplace_id This query parameter specifies the eBay marketplace of the policies you want to retrieve. For implementation help, refer to eBay API documentation at https://developer.ebay.com/api-docs/sell/account/types/ba:MarketplaceIdEnum (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Psr7\Request
*/
public function getPaymentPoliciesRequest($marketplace_id)
{
// Verify the required parameter 'marketplace_id' is set.
if ($marketplace_id === null || (\is_array($marketplace_id) && count($marketplace_id) === 0)) {
throw new \InvalidArgumentException('Missing the required parameter $marketplace_id when calling getPaymentPolicies');
}
$resourcePath = '/payment_policy';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
$marketplace_id,
'marketplace_id', // 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
);
$query = ObjectSerializer::buildQuery($queryParams);
return new Request(
'GET',
$this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getPaymentPolicy.
*
* @param string $payment_policy_id This path parameter specifies the ID of the payment policy you want to retrieve. (required)
*
* @throws \TNT\Ebay\Sell\Account\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return \TNT\Ebay\Sell\Account\V1\Model\PaymentPolicy
*/
public function getPaymentPolicy($payment_policy_id)
{
[$response] = $this->getPaymentPolicyWithHttpInfo($payment_policy_id);
return $response;
}
/**
* Operation getPaymentPolicyWithHttpInfo.
*
* @param string $payment_policy_id This path parameter specifies the ID of the payment policy you want to retrieve. (required)
*
* @throws \TNT\Ebay\Sell\Account\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return array of \TNT\Ebay\Sell\Account\V1\Model\PaymentPolicy, HTTP status code, HTTP response headers (array of strings)
*/
public function getPaymentPolicyWithHttpInfo($payment_policy_id)
{
$request = $this->getPaymentPolicyRequest($payment_policy_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\Account\V1\Model\PaymentPolicy' === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, '\TNT\Ebay\Sell\Account\V1\Model\PaymentPolicy', []),
$response->getStatusCode(),
$response->getHeaders(),
];
}
$returnType = '\TNT\Ebay\Sell\Account\V1\Model\PaymentPolicy';
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\PaymentPolicy',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getPaymentPolicyAsync.
*
* @param string $payment_policy_id This path parameter specifies the ID of the payment policy you want to retrieve. (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getPaymentPolicyAsync($payment_policy_id)
{
return $this->getPaymentPolicyAsyncWithHttpInfo($payment_policy_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getPaymentPolicyAsyncWithHttpInfo.
*
* @param string $payment_policy_id This path parameter specifies the ID of the payment policy you want to retrieve. (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getPaymentPolicyAsyncWithHttpInfo($payment_policy_id)
{
$returnType = '\TNT\Ebay\Sell\Account\V1\Model\PaymentPolicy';
$request = $this->getPaymentPolicyRequest($payment_policy_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 'getPaymentPolicy'.
*
* @param string $payment_policy_id This path parameter specifies the ID of the payment policy you want to retrieve. (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Psr7\Request
*/
public function getPaymentPolicyRequest($payment_policy_id)
{
// Verify the required parameter 'payment_policy_id' is set.
if ($payment_policy_id === null || (\is_array($payment_policy_id) && count($payment_policy_id) === 0)) {
throw new \InvalidArgumentException('Missing the required parameter $payment_policy_id when calling getPaymentPolicy');
}
$resourcePath = '/payment_policy/{payment_policy_id}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// path params
if ($payment_policy_id !== null) {
$resourcePath = str_replace(
'{payment_policy_id}',
ObjectSerializer::toPathValue($payment_policy_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 getPaymentPolicyByName.
*
* @param string $marketplace_id This query parameter specifies the eBay marketplace of the policy you want to retrieve. For implementation help, refer to eBay API documentation at https://developer.ebay.com/api-docs/sell/account/types/ba:MarketplaceIdEnum (required)
* @param string $name This query parameter specifies the seller-defined name of the payment policy you want to retrieve. (required)
*
* @throws \TNT\Ebay\Sell\Account\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return \TNT\Ebay\Sell\Account\V1\Model\PaymentPolicy
*/
public function getPaymentPolicyByName($marketplace_id, $name)
{
[$response] = $this->getPaymentPolicyByNameWithHttpInfo($marketplace_id, $name);
return $response;
}
/**
* Operation getPaymentPolicyByNameWithHttpInfo.
*
* @param string $marketplace_id This query parameter specifies the eBay marketplace of the policy you want to retrieve. For implementation help, refer to eBay API documentation at https://developer.ebay.com/api-docs/sell/account/types/ba:MarketplaceIdEnum (required)
* @param string $name This query parameter specifies the seller-defined name of the payment policy you want to retrieve. (required)
*
* @throws \TNT\Ebay\Sell\Account\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return array of \TNT\Ebay\Sell\Account\V1\Model\PaymentPolicy, HTTP status code, HTTP response headers (array of strings)
*/
public function getPaymentPolicyByNameWithHttpInfo($marketplace_id, $name)
{
$request = $this->getPaymentPolicyByNameRequest($marketplace_id, $name);
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\PaymentPolicy' === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, '\TNT\Ebay\Sell\Account\V1\Model\PaymentPolicy', []),
$response->getStatusCode(),
$response->getHeaders(),
];
}
$returnType = '\TNT\Ebay\Sell\Account\V1\Model\PaymentPolicy';
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\PaymentPolicy',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getPaymentPolicyByNameAsync.
*
* @param string $marketplace_id This query parameter specifies the eBay marketplace of the policy you want to retrieve. For implementation help, refer to eBay API documentation at https://developer.ebay.com/api-docs/sell/account/types/ba:MarketplaceIdEnum (required)
* @param string $name This query parameter specifies the seller-defined name of the payment policy you want to retrieve. (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getPaymentPolicyByNameAsync($marketplace_id, $name)
{
return $this->getPaymentPolicyByNameAsyncWithHttpInfo($marketplace_id, $name)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getPaymentPolicyByNameAsyncWithHttpInfo.
*
* @param string $marketplace_id This query parameter specifies the eBay marketplace of the policy you want to retrieve. For implementation help, refer to eBay API documentation at https://developer.ebay.com/api-docs/sell/account/types/ba:MarketplaceIdEnum (required)
* @param string $name This query parameter specifies the seller-defined name of the payment policy you want to retrieve. (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getPaymentPolicyByNameAsyncWithHttpInfo($marketplace_id, $name)
{
$returnType = '\TNT\Ebay\Sell\Account\V1\Model\PaymentPolicy';
$request = $this->getPaymentPolicyByNameRequest($marketplace_id, $name);
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 'getPaymentPolicyByName'.
*
* @param string $marketplace_id This query parameter specifies the eBay marketplace of the policy you want to retrieve. For implementation help, refer to eBay API documentation at https://developer.ebay.com/api-docs/sell/account/types/ba:MarketplaceIdEnum (required)
* @param string $name This query parameter specifies the seller-defined name of the payment policy you want to retrieve. (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Psr7\Request
*/
public function getPaymentPolicyByNameRequest($marketplace_id, $name)
{
// Verify the required parameter 'marketplace_id' is set.
if ($marketplace_id === null || (\is_array($marketplace_id) && count($marketplace_id) === 0)) {
throw new \InvalidArgumentException('Missing the required parameter $marketplace_id when calling getPaymentPolicyByName');
}
// Verify the required parameter 'name' is set.
if ($name === null || (\is_array($name) && count($name) === 0)) {
throw new \InvalidArgumentException('Missing the required parameter $name when calling getPaymentPolicyByName');
}
$resourcePath = '/payment_policy/get_by_policy_name';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
$marketplace_id,
'marketplace_id', // param base name
'string', // openApiType
'form', // style
true // explode
) ?? []);
// query params
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
$name,
'name', // 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
);
$query = ObjectSerializer::buildQuery($queryParams);
return new Request(
'GET',
$this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation updatePaymentPolicy.
*
* @param string $payment_policy_id This path parameter specifies the ID of the payment policy you want to update. (required)
* @param \TNT\Ebay\Sell\Account\V1\Model\PaymentPolicyRequest $payment_policy_request Payment policy request (required)
*
* @throws \TNT\Ebay\Sell\Account\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return \TNT\Ebay\Sell\Account\V1\Model\SetPaymentPolicyResponse
*/
public function updatePaymentPolicy($payment_policy_id, $payment_policy_request)
{
[$response] = $this->updatePaymentPolicyWithHttpInfo($payment_policy_id, $payment_policy_request);
return $response;
}
/**
* Operation updatePaymentPolicyWithHttpInfo.
*
* @param string $payment_policy_id This path parameter specifies the ID of the payment policy you want to update. (required)
* @param \TNT\Ebay\Sell\Account\V1\Model\PaymentPolicyRequest $payment_policy_request Payment policy request (required)
*
* @throws \TNT\Ebay\Sell\Account\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return array of \TNT\Ebay\Sell\Account\V1\Model\SetPaymentPolicyResponse, HTTP status code, HTTP response headers (array of strings)
*/
public function updatePaymentPolicyWithHttpInfo($payment_policy_id, $payment_policy_request)
{
$request = $this->updatePaymentPolicyRequest($payment_policy_id, $payment_policy_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\Account\V1\Model\SetPaymentPolicyResponse' === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, '\TNT\Ebay\Sell\Account\V1\Model\SetPaymentPolicyResponse', []),
$response->getStatusCode(),
$response->getHeaders(),
];
}
$returnType = '\TNT\Ebay\Sell\Account\V1\Model\SetPaymentPolicyResponse';
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\SetPaymentPolicyResponse',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation updatePaymentPolicyAsync.
*
* @param string $payment_policy_id This path parameter specifies the ID of the payment policy you want to update. (required)
* @param \TNT\Ebay\Sell\Account\V1\Model\PaymentPolicyRequest $payment_policy_request Payment policy request (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updatePaymentPolicyAsync($payment_policy_id, $payment_policy_request)
{
return $this->updatePaymentPolicyAsyncWithHttpInfo($payment_policy_id, $payment_policy_request)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation updatePaymentPolicyAsyncWithHttpInfo.
*
* @param string $payment_policy_id This path parameter specifies the ID of the payment policy you want to update. (required)
* @param \TNT\Ebay\Sell\Account\V1\Model\PaymentPolicyRequest $payment_policy_request Payment policy request (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updatePaymentPolicyAsyncWithHttpInfo($payment_policy_id, $payment_policy_request)
{
$returnType = '\TNT\Ebay\Sell\Account\V1\Model\SetPaymentPolicyResponse';
$request = $this->updatePaymentPolicyRequest($payment_policy_id, $payment_policy_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 'updatePaymentPolicy'.
*
* @param string $payment_policy_id This path parameter specifies the ID of the payment policy you want to update. (required)
* @param \TNT\Ebay\Sell\Account\V1\Model\PaymentPolicyRequest $payment_policy_request Payment policy request (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Psr7\Request
*/
public function updatePaymentPolicyRequest($payment_policy_id, $payment_policy_request)
{
// Verify the required parameter 'payment_policy_id' is set.
if ($payment_policy_id === null || (\is_array($payment_policy_id) && count($payment_policy_id) === 0)) {
throw new \InvalidArgumentException('Missing the required parameter $payment_policy_id when calling updatePaymentPolicy');
}
// Verify the required parameter 'payment_policy_request' is set.
if ($payment_policy_request === null || (\is_array($payment_policy_request) && count($payment_policy_request) === 0)) {
throw new \InvalidArgumentException('Missing the required parameter $payment_policy_request when calling updatePaymentPolicy');
}
$resourcePath = '/payment_policy/{payment_policy_id}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// path params
if ($payment_policy_id !== null) {
$resourcePath = str_replace(
'{payment_policy_id}',
ObjectSerializer::toPathValue($payment_policy_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($payment_policy_request)) {
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($payment_policy_request));
} else {
$httpBody = $payment_policy_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(
'PUT',
$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;
}
}