src/Buy/Order/V2/Api/GuestCheckoutSessionApi.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);
/**
* GuestCheckoutSessionApi.
*
* PHP version ^7.2 || ^8.0
*
* @category Class
*
* @author OpenAPI Generator team
*
* @see https://openapi-generator.tech
*/
/**
* Order API.
*
* <span class=\"tablenote\"><b>Note:</b> The Order API (v2) currently only supports the guest payment/checkout flow. If you need to support member payment/checkout flow, use the <a href=\"/api-docs/buy/order_v1/resources/methods\">v1_beta version</a> of the Order API.</span><br /><br /><span class=\"tablenote\"><b>Note:</b> This is a <a href=\"https://developer.ebay.com/api-docs/static/versioning.html#limited\" target=\"_blank\"><img src=\"/cms/img/docs/partners-api.svg\" class=\"legend-icon partners-icon\" alt=\"Limited Release\" title=\"Limited Release\" />(Limited Release)</a> API available only to select developers approved by business units.</span><br /><br />The Order API provides interfaces that let shoppers pay for items. It also returns payment and shipping status of the order.
*
* The version of the OpenAPI document: v2.1.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\Buy\Order\V2\Api;
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\RequestOptions;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Psr7\MultipartStream;
use TNT\Ebay\Buy\Order\V2\ApiException;
use TNT\Ebay\Buy\Order\V2\Configuration;
use GuzzleHttp\Exception\GuzzleException;
use TNT\Ebay\Buy\Order\V2\HeaderSelector;
use GuzzleHttp\Exception\ConnectException;
use GuzzleHttp\Exception\RequestException;
use TNT\Ebay\Buy\Order\V2\ObjectSerializer;
/**
* GuestCheckoutSessionApi Class Doc Comment.
*
* @category Class
*
* @author OpenAPI Generator team
*
* @see https://openapi-generator.tech
*/
class GuestCheckoutSessionApi
{
/**
* @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 applyGuestCoupon.
*
* @param string $checkout_session_id The eBay-assigned session ID, for a specific eBay marketplace, that is returned by the <b> initiateGuestCheckoutSession</b> method.<br /><br /><span class=\"tablenote\"><b>Note:</b> When using this ID, the X-EBAY-C-MARKETPLACE-ID value and developer App ID must be the same as that used when this guest checkout session was created. See <a href=\"/api-docs/buy/order/overview.html#checkout-restriction\">Checkout session restrictions</a> in the Buy Integration Guide for details.</span> (required)
* @param string $x_ebay_c_marketplace_id A header that identifies the user's business context and is specified using a marketplace ID value.<br /><br /><span class=\"tablenote\"><b>Note:</b> This header does <i>not</i> indicate a language preference or consumer location.</span><br /><br />See <a href=\"/api-docs/static/rest-request-components.html#marketpl\" target=\"_blank\">Marketplace ID values</a> for a list of supported values. (required)
* @param \TNT\Ebay\Buy\Order\V2\Model\CouponRequest $coupon_request The container for the fields used to apply a coupon to a guest checkout session. (optional)
*
* @throws \TNT\Ebay\Buy\Order\V2\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return \TNT\Ebay\Buy\Order\V2\Model\GuestCheckoutSessionResponseV2
*/
public function applyGuestCoupon($checkout_session_id, $x_ebay_c_marketplace_id, $coupon_request = null)
{
[$response] = $this->applyGuestCouponWithHttpInfo($checkout_session_id, $x_ebay_c_marketplace_id, $coupon_request);
return $response;
}
/**
* Operation applyGuestCouponWithHttpInfo.
*
* @param string $checkout_session_id The eBay-assigned session ID, for a specific eBay marketplace, that is returned by the <b> initiateGuestCheckoutSession</b> method.<br /><br /><span class=\"tablenote\"><b>Note:</b> When using this ID, the X-EBAY-C-MARKETPLACE-ID value and developer App ID must be the same as that used when this guest checkout session was created. See <a href=\"/api-docs/buy/order/overview.html#checkout-restriction\">Checkout session restrictions</a> in the Buy Integration Guide for details.</span> (required)
* @param string $x_ebay_c_marketplace_id A header that identifies the user's business context and is specified using a marketplace ID value.<br /><br /><span class=\"tablenote\"><b>Note:</b> This header does <i>not</i> indicate a language preference or consumer location.</span><br /><br />See <a href=\"/api-docs/static/rest-request-components.html#marketpl\" target=\"_blank\">Marketplace ID values</a> for a list of supported values. (required)
* @param \TNT\Ebay\Buy\Order\V2\Model\CouponRequest $coupon_request The container for the fields used to apply a coupon to a guest checkout session. (optional)
*
* @throws \TNT\Ebay\Buy\Order\V2\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return array of \TNT\Ebay\Buy\Order\V2\Model\GuestCheckoutSessionResponseV2, HTTP status code, HTTP response headers (array of strings)
*/
public function applyGuestCouponWithHttpInfo($checkout_session_id, $x_ebay_c_marketplace_id, $coupon_request = null)
{
$request = $this->applyGuestCouponRequest($checkout_session_id, $x_ebay_c_marketplace_id, $coupon_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\Buy\Order\V2\Model\GuestCheckoutSessionResponseV2' === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, '\TNT\Ebay\Buy\Order\V2\Model\GuestCheckoutSessionResponseV2', []),
$response->getStatusCode(),
$response->getHeaders(),
];
}
$returnType = '\TNT\Ebay\Buy\Order\V2\Model\GuestCheckoutSessionResponseV2';
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\Buy\Order\V2\Model\GuestCheckoutSessionResponseV2',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation applyGuestCouponAsync.
*
* @param string $checkout_session_id The eBay-assigned session ID, for a specific eBay marketplace, that is returned by the <b> initiateGuestCheckoutSession</b> method.<br /><br /><span class=\"tablenote\"><b>Note:</b> When using this ID, the X-EBAY-C-MARKETPLACE-ID value and developer App ID must be the same as that used when this guest checkout session was created. See <a href=\"/api-docs/buy/order/overview.html#checkout-restriction\">Checkout session restrictions</a> in the Buy Integration Guide for details.</span> (required)
* @param string $x_ebay_c_marketplace_id A header that identifies the user's business context and is specified using a marketplace ID value.<br /><br /><span class=\"tablenote\"><b>Note:</b> This header does <i>not</i> indicate a language preference or consumer location.</span><br /><br />See <a href=\"/api-docs/static/rest-request-components.html#marketpl\" target=\"_blank\">Marketplace ID values</a> for a list of supported values. (required)
* @param \TNT\Ebay\Buy\Order\V2\Model\CouponRequest $coupon_request The container for the fields used to apply a coupon to a guest checkout session. (optional)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function applyGuestCouponAsync($checkout_session_id, $x_ebay_c_marketplace_id, $coupon_request = null)
{
return $this->applyGuestCouponAsyncWithHttpInfo($checkout_session_id, $x_ebay_c_marketplace_id, $coupon_request)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation applyGuestCouponAsyncWithHttpInfo.
*
* @param string $checkout_session_id The eBay-assigned session ID, for a specific eBay marketplace, that is returned by the <b> initiateGuestCheckoutSession</b> method.<br /><br /><span class=\"tablenote\"><b>Note:</b> When using this ID, the X-EBAY-C-MARKETPLACE-ID value and developer App ID must be the same as that used when this guest checkout session was created. See <a href=\"/api-docs/buy/order/overview.html#checkout-restriction\">Checkout session restrictions</a> in the Buy Integration Guide for details.</span> (required)
* @param string $x_ebay_c_marketplace_id A header that identifies the user's business context and is specified using a marketplace ID value.<br /><br /><span class=\"tablenote\"><b>Note:</b> This header does <i>not</i> indicate a language preference or consumer location.</span><br /><br />See <a href=\"/api-docs/static/rest-request-components.html#marketpl\" target=\"_blank\">Marketplace ID values</a> for a list of supported values. (required)
* @param \TNT\Ebay\Buy\Order\V2\Model\CouponRequest $coupon_request The container for the fields used to apply a coupon to a guest checkout session. (optional)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function applyGuestCouponAsyncWithHttpInfo($checkout_session_id, $x_ebay_c_marketplace_id, $coupon_request = null)
{
$returnType = '\TNT\Ebay\Buy\Order\V2\Model\GuestCheckoutSessionResponseV2';
$request = $this->applyGuestCouponRequest($checkout_session_id, $x_ebay_c_marketplace_id, $coupon_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 'applyGuestCoupon'.
*
* @param string $checkout_session_id The eBay-assigned session ID, for a specific eBay marketplace, that is returned by the <b> initiateGuestCheckoutSession</b> method.<br /><br /><span class=\"tablenote\"><b>Note:</b> When using this ID, the X-EBAY-C-MARKETPLACE-ID value and developer App ID must be the same as that used when this guest checkout session was created. See <a href=\"/api-docs/buy/order/overview.html#checkout-restriction\">Checkout session restrictions</a> in the Buy Integration Guide for details.</span> (required)
* @param string $x_ebay_c_marketplace_id A header that identifies the user's business context and is specified using a marketplace ID value.<br /><br /><span class=\"tablenote\"><b>Note:</b> This header does <i>not</i> indicate a language preference or consumer location.</span><br /><br />See <a href=\"/api-docs/static/rest-request-components.html#marketpl\" target=\"_blank\">Marketplace ID values</a> for a list of supported values. (required)
* @param \TNT\Ebay\Buy\Order\V2\Model\CouponRequest $coupon_request The container for the fields used to apply a coupon to a guest checkout session. (optional)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Psr7\Request
*/
public function applyGuestCouponRequest($checkout_session_id, $x_ebay_c_marketplace_id, $coupon_request = null)
{
// Verify the required parameter 'checkout_session_id' is set.
if ($checkout_session_id === null || (\is_array($checkout_session_id) && count($checkout_session_id) === 0)) {
throw new \InvalidArgumentException('Missing the required parameter $checkout_session_id when calling applyGuestCoupon');
}
// Verify the required parameter 'x_ebay_c_marketplace_id' is set.
if ($x_ebay_c_marketplace_id === null || (\is_array($x_ebay_c_marketplace_id) && count($x_ebay_c_marketplace_id) === 0)) {
throw new \InvalidArgumentException('Missing the required parameter $x_ebay_c_marketplace_id when calling applyGuestCoupon');
}
$resourcePath = '/guest_checkout_session/{checkoutSessionId}/apply_coupon';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($x_ebay_c_marketplace_id !== null) {
$headerParams['X-EBAY-C-MARKETPLACE-ID'] = ObjectSerializer::toHeaderValue($x_ebay_c_marketplace_id);
}
// path params
if ($checkout_session_id !== null) {
$resourcePath = str_replace(
'{checkoutSessionId}',
ObjectSerializer::toPathValue($checkout_session_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($coupon_request)) {
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($coupon_request));
} else {
$httpBody = $coupon_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();
}
$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 getGuestCheckoutSession.
*
* @param string $checkout_session_id The eBay-assigned session ID, for a specific eBay marketplace, that is returned by the <b> initiateGuestCheckoutSession</b> method.<br /><br /><span class=\"tablenote\"><b>Note:</b> When using this ID, the X-EBAY-C-MARKETPLACE-ID value and developer App ID must be the same as that used when this guest checkout session was created. See <a href=\"/api-docs/buy/order/overview.html#checkout-restriction\">Checkout session restrictions</a> in the Buy Integration Guide for details.</span> (required)
* @param string $x_ebay_c_marketplace_id A header that identifies the user's business context and is specified using a marketplace ID value.<br /><br /><span class=\"tablenote\"><b>Note:</b> This header does <i>not</i> indicate a language preference or consumer location.</span><br /><br />See <a href=\"/api-docs/static/rest-request-components.html#marketpl\" target=\"_blank\">Marketplace ID values</a> for a list of supported values. (required)
*
* @throws \TNT\Ebay\Buy\Order\V2\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return \TNT\Ebay\Buy\Order\V2\Model\GuestCheckoutSessionResponseV2
*/
public function getGuestCheckoutSession($checkout_session_id, $x_ebay_c_marketplace_id)
{
[$response] = $this->getGuestCheckoutSessionWithHttpInfo($checkout_session_id, $x_ebay_c_marketplace_id);
return $response;
}
/**
* Operation getGuestCheckoutSessionWithHttpInfo.
*
* @param string $checkout_session_id The eBay-assigned session ID, for a specific eBay marketplace, that is returned by the <b> initiateGuestCheckoutSession</b> method.<br /><br /><span class=\"tablenote\"><b>Note:</b> When using this ID, the X-EBAY-C-MARKETPLACE-ID value and developer App ID must be the same as that used when this guest checkout session was created. See <a href=\"/api-docs/buy/order/overview.html#checkout-restriction\">Checkout session restrictions</a> in the Buy Integration Guide for details.</span> (required)
* @param string $x_ebay_c_marketplace_id A header that identifies the user's business context and is specified using a marketplace ID value.<br /><br /><span class=\"tablenote\"><b>Note:</b> This header does <i>not</i> indicate a language preference or consumer location.</span><br /><br />See <a href=\"/api-docs/static/rest-request-components.html#marketpl\" target=\"_blank\">Marketplace ID values</a> for a list of supported values. (required)
*
* @throws \TNT\Ebay\Buy\Order\V2\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return array of \TNT\Ebay\Buy\Order\V2\Model\GuestCheckoutSessionResponseV2, HTTP status code, HTTP response headers (array of strings)
*/
public function getGuestCheckoutSessionWithHttpInfo($checkout_session_id, $x_ebay_c_marketplace_id)
{
$request = $this->getGuestCheckoutSessionRequest($checkout_session_id, $x_ebay_c_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\Buy\Order\V2\Model\GuestCheckoutSessionResponseV2' === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, '\TNT\Ebay\Buy\Order\V2\Model\GuestCheckoutSessionResponseV2', []),
$response->getStatusCode(),
$response->getHeaders(),
];
}
$returnType = '\TNT\Ebay\Buy\Order\V2\Model\GuestCheckoutSessionResponseV2';
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\Buy\Order\V2\Model\GuestCheckoutSessionResponseV2',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getGuestCheckoutSessionAsync.
*
* @param string $checkout_session_id The eBay-assigned session ID, for a specific eBay marketplace, that is returned by the <b> initiateGuestCheckoutSession</b> method.<br /><br /><span class=\"tablenote\"><b>Note:</b> When using this ID, the X-EBAY-C-MARKETPLACE-ID value and developer App ID must be the same as that used when this guest checkout session was created. See <a href=\"/api-docs/buy/order/overview.html#checkout-restriction\">Checkout session restrictions</a> in the Buy Integration Guide for details.</span> (required)
* @param string $x_ebay_c_marketplace_id A header that identifies the user's business context and is specified using a marketplace ID value.<br /><br /><span class=\"tablenote\"><b>Note:</b> This header does <i>not</i> indicate a language preference or consumer location.</span><br /><br />See <a href=\"/api-docs/static/rest-request-components.html#marketpl\" target=\"_blank\">Marketplace ID values</a> for a list of supported values. (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getGuestCheckoutSessionAsync($checkout_session_id, $x_ebay_c_marketplace_id)
{
return $this->getGuestCheckoutSessionAsyncWithHttpInfo($checkout_session_id, $x_ebay_c_marketplace_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getGuestCheckoutSessionAsyncWithHttpInfo.
*
* @param string $checkout_session_id The eBay-assigned session ID, for a specific eBay marketplace, that is returned by the <b> initiateGuestCheckoutSession</b> method.<br /><br /><span class=\"tablenote\"><b>Note:</b> When using this ID, the X-EBAY-C-MARKETPLACE-ID value and developer App ID must be the same as that used when this guest checkout session was created. See <a href=\"/api-docs/buy/order/overview.html#checkout-restriction\">Checkout session restrictions</a> in the Buy Integration Guide for details.</span> (required)
* @param string $x_ebay_c_marketplace_id A header that identifies the user's business context and is specified using a marketplace ID value.<br /><br /><span class=\"tablenote\"><b>Note:</b> This header does <i>not</i> indicate a language preference or consumer location.</span><br /><br />See <a href=\"/api-docs/static/rest-request-components.html#marketpl\" target=\"_blank\">Marketplace ID values</a> for a list of supported values. (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getGuestCheckoutSessionAsyncWithHttpInfo($checkout_session_id, $x_ebay_c_marketplace_id)
{
$returnType = '\TNT\Ebay\Buy\Order\V2\Model\GuestCheckoutSessionResponseV2';
$request = $this->getGuestCheckoutSessionRequest($checkout_session_id, $x_ebay_c_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 'getGuestCheckoutSession'.
*
* @param string $checkout_session_id The eBay-assigned session ID, for a specific eBay marketplace, that is returned by the <b> initiateGuestCheckoutSession</b> method.<br /><br /><span class=\"tablenote\"><b>Note:</b> When using this ID, the X-EBAY-C-MARKETPLACE-ID value and developer App ID must be the same as that used when this guest checkout session was created. See <a href=\"/api-docs/buy/order/overview.html#checkout-restriction\">Checkout session restrictions</a> in the Buy Integration Guide for details.</span> (required)
* @param string $x_ebay_c_marketplace_id A header that identifies the user's business context and is specified using a marketplace ID value.<br /><br /><span class=\"tablenote\"><b>Note:</b> This header does <i>not</i> indicate a language preference or consumer location.</span><br /><br />See <a href=\"/api-docs/static/rest-request-components.html#marketpl\" target=\"_blank\">Marketplace ID values</a> for a list of supported values. (required)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Psr7\Request
*/
public function getGuestCheckoutSessionRequest($checkout_session_id, $x_ebay_c_marketplace_id)
{
// Verify the required parameter 'checkout_session_id' is set.
if ($checkout_session_id === null || (\is_array($checkout_session_id) && count($checkout_session_id) === 0)) {
throw new \InvalidArgumentException('Missing the required parameter $checkout_session_id when calling getGuestCheckoutSession');
}
// Verify the required parameter 'x_ebay_c_marketplace_id' is set.
if ($x_ebay_c_marketplace_id === null || (\is_array($x_ebay_c_marketplace_id) && count($x_ebay_c_marketplace_id) === 0)) {
throw new \InvalidArgumentException('Missing the required parameter $x_ebay_c_marketplace_id when calling getGuestCheckoutSession');
}
$resourcePath = '/guest_checkout_session/{checkoutSessionId}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($x_ebay_c_marketplace_id !== null) {
$headerParams['X-EBAY-C-MARKETPLACE-ID'] = ObjectSerializer::toHeaderValue($x_ebay_c_marketplace_id);
}
// path params
if ($checkout_session_id !== null) {
$resourcePath = str_replace(
'{checkoutSessionId}',
ObjectSerializer::toPathValue($checkout_session_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();
}
$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 initiateGuestCheckoutSession.
*
* @param string $x_ebay_c_marketplace_id A header that identifies the user's business context and is specified using a marketplace ID value.<br /><br /><span class=\"tablenote\"><b>Note:</b> This header does <i>not</i> indicate a language preference or consumer location.</span><br /><br />See <a href=\"/api-docs/static/rest-request-components.html#marketpl\" target=\"_blank\">Marketplace ID values</a> for a list of supported values. (required)
* @param string $x_ebay_c_enduserctx A header that is used to specify the <b>affiliateCampaignId</b>, and optionally the <b>affiliateReferenceId</b>, to enable revenue sharing when the buyer purchases items.<br /><br /><span class=\"tablenote\"><font color=\"006600\"><b>TIP:</b></font> See <a href=\"/api-docs/buy/static/api-browse.html#Headers\" target=\"_blank\">Request headers</a> in the Buying Integration Guide for more information.</span> (optional)
* @param \TNT\Ebay\Buy\Order\V2\Model\CreateGuestCheckoutSessionRequestV2 $create_guest_checkout_session_request_v2 The container for the fields used by the <b>initiateGuestCheckoutSession</b> method. (optional)
*
* @throws \TNT\Ebay\Buy\Order\V2\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return \TNT\Ebay\Buy\Order\V2\Model\GuestCheckoutSessionResponseV2
*/
public function initiateGuestCheckoutSession($x_ebay_c_marketplace_id, $x_ebay_c_enduserctx = null, $create_guest_checkout_session_request_v2 = null)
{
[$response] = $this->initiateGuestCheckoutSessionWithHttpInfo($x_ebay_c_marketplace_id, $x_ebay_c_enduserctx, $create_guest_checkout_session_request_v2);
return $response;
}
/**
* Operation initiateGuestCheckoutSessionWithHttpInfo.
*
* @param string $x_ebay_c_marketplace_id A header that identifies the user's business context and is specified using a marketplace ID value.<br /><br /><span class=\"tablenote\"><b>Note:</b> This header does <i>not</i> indicate a language preference or consumer location.</span><br /><br />See <a href=\"/api-docs/static/rest-request-components.html#marketpl\" target=\"_blank\">Marketplace ID values</a> for a list of supported values. (required)
* @param string $x_ebay_c_enduserctx A header that is used to specify the <b>affiliateCampaignId</b>, and optionally the <b>affiliateReferenceId</b>, to enable revenue sharing when the buyer purchases items.<br /><br /><span class=\"tablenote\"><font color=\"006600\"><b>TIP:</b></font> See <a href=\"/api-docs/buy/static/api-browse.html#Headers\" target=\"_blank\">Request headers</a> in the Buying Integration Guide for more information.</span> (optional)
* @param \TNT\Ebay\Buy\Order\V2\Model\CreateGuestCheckoutSessionRequestV2 $create_guest_checkout_session_request_v2 The container for the fields used by the <b>initiateGuestCheckoutSession</b> method. (optional)
*
* @throws \TNT\Ebay\Buy\Order\V2\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return array of \TNT\Ebay\Buy\Order\V2\Model\GuestCheckoutSessionResponseV2, HTTP status code, HTTP response headers (array of strings)
*/
public function initiateGuestCheckoutSessionWithHttpInfo($x_ebay_c_marketplace_id, $x_ebay_c_enduserctx = null, $create_guest_checkout_session_request_v2 = null)
{
$request = $this->initiateGuestCheckoutSessionRequest($x_ebay_c_marketplace_id, $x_ebay_c_enduserctx, $create_guest_checkout_session_request_v2);
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\Buy\Order\V2\Model\GuestCheckoutSessionResponseV2' === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, '\TNT\Ebay\Buy\Order\V2\Model\GuestCheckoutSessionResponseV2', []),
$response->getStatusCode(),
$response->getHeaders(),
];
}
$returnType = '\TNT\Ebay\Buy\Order\V2\Model\GuestCheckoutSessionResponseV2';
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\Buy\Order\V2\Model\GuestCheckoutSessionResponseV2',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation initiateGuestCheckoutSessionAsync.
*
* @param string $x_ebay_c_marketplace_id A header that identifies the user's business context and is specified using a marketplace ID value.<br /><br /><span class=\"tablenote\"><b>Note:</b> This header does <i>not</i> indicate a language preference or consumer location.</span><br /><br />See <a href=\"/api-docs/static/rest-request-components.html#marketpl\" target=\"_blank\">Marketplace ID values</a> for a list of supported values. (required)
* @param string $x_ebay_c_enduserctx A header that is used to specify the <b>affiliateCampaignId</b>, and optionally the <b>affiliateReferenceId</b>, to enable revenue sharing when the buyer purchases items.<br /><br /><span class=\"tablenote\"><font color=\"006600\"><b>TIP:</b></font> See <a href=\"/api-docs/buy/static/api-browse.html#Headers\" target=\"_blank\">Request headers</a> in the Buying Integration Guide for more information.</span> (optional)
* @param \TNT\Ebay\Buy\Order\V2\Model\CreateGuestCheckoutSessionRequestV2 $create_guest_checkout_session_request_v2 The container for the fields used by the <b>initiateGuestCheckoutSession</b> method. (optional)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function initiateGuestCheckoutSessionAsync($x_ebay_c_marketplace_id, $x_ebay_c_enduserctx = null, $create_guest_checkout_session_request_v2 = null)
{
return $this->initiateGuestCheckoutSessionAsyncWithHttpInfo($x_ebay_c_marketplace_id, $x_ebay_c_enduserctx, $create_guest_checkout_session_request_v2)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation initiateGuestCheckoutSessionAsyncWithHttpInfo.
*
* @param string $x_ebay_c_marketplace_id A header that identifies the user's business context and is specified using a marketplace ID value.<br /><br /><span class=\"tablenote\"><b>Note:</b> This header does <i>not</i> indicate a language preference or consumer location.</span><br /><br />See <a href=\"/api-docs/static/rest-request-components.html#marketpl\" target=\"_blank\">Marketplace ID values</a> for a list of supported values. (required)
* @param string $x_ebay_c_enduserctx A header that is used to specify the <b>affiliateCampaignId</b>, and optionally the <b>affiliateReferenceId</b>, to enable revenue sharing when the buyer purchases items.<br /><br /><span class=\"tablenote\"><font color=\"006600\"><b>TIP:</b></font> See <a href=\"/api-docs/buy/static/api-browse.html#Headers\" target=\"_blank\">Request headers</a> in the Buying Integration Guide for more information.</span> (optional)
* @param \TNT\Ebay\Buy\Order\V2\Model\CreateGuestCheckoutSessionRequestV2 $create_guest_checkout_session_request_v2 The container for the fields used by the <b>initiateGuestCheckoutSession</b> method. (optional)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function initiateGuestCheckoutSessionAsyncWithHttpInfo($x_ebay_c_marketplace_id, $x_ebay_c_enduserctx = null, $create_guest_checkout_session_request_v2 = null)
{
$returnType = '\TNT\Ebay\Buy\Order\V2\Model\GuestCheckoutSessionResponseV2';
$request = $this->initiateGuestCheckoutSessionRequest($x_ebay_c_marketplace_id, $x_ebay_c_enduserctx, $create_guest_checkout_session_request_v2);
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 'initiateGuestCheckoutSession'.
*
* @param string $x_ebay_c_marketplace_id A header that identifies the user's business context and is specified using a marketplace ID value.<br /><br /><span class=\"tablenote\"><b>Note:</b> This header does <i>not</i> indicate a language preference or consumer location.</span><br /><br />See <a href=\"/api-docs/static/rest-request-components.html#marketpl\" target=\"_blank\">Marketplace ID values</a> for a list of supported values. (required)
* @param string $x_ebay_c_enduserctx A header that is used to specify the <b>affiliateCampaignId</b>, and optionally the <b>affiliateReferenceId</b>, to enable revenue sharing when the buyer purchases items.<br /><br /><span class=\"tablenote\"><font color=\"006600\"><b>TIP:</b></font> See <a href=\"/api-docs/buy/static/api-browse.html#Headers\" target=\"_blank\">Request headers</a> in the Buying Integration Guide for more information.</span> (optional)
* @param \TNT\Ebay\Buy\Order\V2\Model\CreateGuestCheckoutSessionRequestV2 $create_guest_checkout_session_request_v2 The container for the fields used by the <b>initiateGuestCheckoutSession</b> method. (optional)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Psr7\Request
*/
public function initiateGuestCheckoutSessionRequest($x_ebay_c_marketplace_id, $x_ebay_c_enduserctx = null, $create_guest_checkout_session_request_v2 = null)
{
// Verify the required parameter 'x_ebay_c_marketplace_id' is set.
if ($x_ebay_c_marketplace_id === null || (\is_array($x_ebay_c_marketplace_id) && count($x_ebay_c_marketplace_id) === 0)) {
throw new \InvalidArgumentException('Missing the required parameter $x_ebay_c_marketplace_id when calling initiateGuestCheckoutSession');
}
$resourcePath = '/guest_checkout_session/initiate';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($x_ebay_c_enduserctx !== null) {
$headerParams['X-EBAY-C-ENDUSERCTX'] = ObjectSerializer::toHeaderValue($x_ebay_c_enduserctx);
}
// header params
if ($x_ebay_c_marketplace_id !== null) {
$headerParams['X-EBAY-C-MARKETPLACE-ID'] = ObjectSerializer::toHeaderValue($x_ebay_c_marketplace_id);
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// For model (json/xml)
if (isset($create_guest_checkout_session_request_v2)) {
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($create_guest_checkout_session_request_v2));
} else {
$httpBody = $create_guest_checkout_session_request_v2;
}
} 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();
}
$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 removeGuestCoupon.
*
* @param string $checkout_session_id The eBay-assigned session ID, for a specific eBay marketplace, that is returned by the <b> initiateGuestCheckoutSession</b> method.<br /><br /><span class=\"tablenote\"><b>Note:</b> When using this ID, the X-EBAY-C-MARKETPLACE-ID value and developer App ID must be the same as that used when this guest checkout session was created. See <a href=\"/api-docs/buy/order/overview.html#checkout-restriction\">Checkout session restrictions</a> in the Buy Integration Guide for details.</span> (required)
* @param string $x_ebay_c_marketplace_id A header that identifies the user's business context and is specified using a marketplace ID value.<br /><br /><span class=\"tablenote\"><b>Note:</b> This header does <i>not</i> indicate a language preference or consumer location.</span><br /><br />See <a href=\"/api-docs/static/rest-request-components.html#marketpl\" target=\"_blank\">Marketplace ID values</a> for a list of supported values. (required)
* @param \TNT\Ebay\Buy\Order\V2\Model\CouponRequest $coupon_request The container for the fields used by the <b>removeGuestCoupon</b> method. (optional)
*
* @throws \TNT\Ebay\Buy\Order\V2\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return \TNT\Ebay\Buy\Order\V2\Model\GuestCheckoutSessionResponseV2
*/
public function removeGuestCoupon($checkout_session_id, $x_ebay_c_marketplace_id, $coupon_request = null)
{
[$response] = $this->removeGuestCouponWithHttpInfo($checkout_session_id, $x_ebay_c_marketplace_id, $coupon_request);
return $response;
}
/**
* Operation removeGuestCouponWithHttpInfo.
*
* @param string $checkout_session_id The eBay-assigned session ID, for a specific eBay marketplace, that is returned by the <b> initiateGuestCheckoutSession</b> method.<br /><br /><span class=\"tablenote\"><b>Note:</b> When using this ID, the X-EBAY-C-MARKETPLACE-ID value and developer App ID must be the same as that used when this guest checkout session was created. See <a href=\"/api-docs/buy/order/overview.html#checkout-restriction\">Checkout session restrictions</a> in the Buy Integration Guide for details.</span> (required)
* @param string $x_ebay_c_marketplace_id A header that identifies the user's business context and is specified using a marketplace ID value.<br /><br /><span class=\"tablenote\"><b>Note:</b> This header does <i>not</i> indicate a language preference or consumer location.</span><br /><br />See <a href=\"/api-docs/static/rest-request-components.html#marketpl\" target=\"_blank\">Marketplace ID values</a> for a list of supported values. (required)
* @param \TNT\Ebay\Buy\Order\V2\Model\CouponRequest $coupon_request The container for the fields used by the <b>removeGuestCoupon</b> method. (optional)
*
* @throws \TNT\Ebay\Buy\Order\V2\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return array of \TNT\Ebay\Buy\Order\V2\Model\GuestCheckoutSessionResponseV2, HTTP status code, HTTP response headers (array of strings)
*/
public function removeGuestCouponWithHttpInfo($checkout_session_id, $x_ebay_c_marketplace_id, $coupon_request = null)
{
$request = $this->removeGuestCouponRequest($checkout_session_id, $x_ebay_c_marketplace_id, $coupon_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\Buy\Order\V2\Model\GuestCheckoutSessionResponseV2' === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, '\TNT\Ebay\Buy\Order\V2\Model\GuestCheckoutSessionResponseV2', []),
$response->getStatusCode(),
$response->getHeaders(),
];
}
$returnType = '\TNT\Ebay\Buy\Order\V2\Model\GuestCheckoutSessionResponseV2';
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\Buy\Order\V2\Model\GuestCheckoutSessionResponseV2',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation removeGuestCouponAsync.
*
* @param string $checkout_session_id The eBay-assigned session ID, for a specific eBay marketplace, that is returned by the <b> initiateGuestCheckoutSession</b> method.<br /><br /><span class=\"tablenote\"><b>Note:</b> When using this ID, the X-EBAY-C-MARKETPLACE-ID value and developer App ID must be the same as that used when this guest checkout session was created. See <a href=\"/api-docs/buy/order/overview.html#checkout-restriction\">Checkout session restrictions</a> in the Buy Integration Guide for details.</span> (required)
* @param string $x_ebay_c_marketplace_id A header that identifies the user's business context and is specified using a marketplace ID value.<br /><br /><span class=\"tablenote\"><b>Note:</b> This header does <i>not</i> indicate a language preference or consumer location.</span><br /><br />See <a href=\"/api-docs/static/rest-request-components.html#marketpl\" target=\"_blank\">Marketplace ID values</a> for a list of supported values. (required)
* @param \TNT\Ebay\Buy\Order\V2\Model\CouponRequest $coupon_request The container for the fields used by the <b>removeGuestCoupon</b> method. (optional)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function removeGuestCouponAsync($checkout_session_id, $x_ebay_c_marketplace_id, $coupon_request = null)
{
return $this->removeGuestCouponAsyncWithHttpInfo($checkout_session_id, $x_ebay_c_marketplace_id, $coupon_request)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation removeGuestCouponAsyncWithHttpInfo.
*
* @param string $checkout_session_id The eBay-assigned session ID, for a specific eBay marketplace, that is returned by the <b> initiateGuestCheckoutSession</b> method.<br /><br /><span class=\"tablenote\"><b>Note:</b> When using this ID, the X-EBAY-C-MARKETPLACE-ID value and developer App ID must be the same as that used when this guest checkout session was created. See <a href=\"/api-docs/buy/order/overview.html#checkout-restriction\">Checkout session restrictions</a> in the Buy Integration Guide for details.</span> (required)
* @param string $x_ebay_c_marketplace_id A header that identifies the user's business context and is specified using a marketplace ID value.<br /><br /><span class=\"tablenote\"><b>Note:</b> This header does <i>not</i> indicate a language preference or consumer location.</span><br /><br />See <a href=\"/api-docs/static/rest-request-components.html#marketpl\" target=\"_blank\">Marketplace ID values</a> for a list of supported values. (required)
* @param \TNT\Ebay\Buy\Order\V2\Model\CouponRequest $coupon_request The container for the fields used by the <b>removeGuestCoupon</b> method. (optional)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function removeGuestCouponAsyncWithHttpInfo($checkout_session_id, $x_ebay_c_marketplace_id, $coupon_request = null)
{
$returnType = '\TNT\Ebay\Buy\Order\V2\Model\GuestCheckoutSessionResponseV2';
$request = $this->removeGuestCouponRequest($checkout_session_id, $x_ebay_c_marketplace_id, $coupon_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 'removeGuestCoupon'.
*
* @param string $checkout_session_id The eBay-assigned session ID, for a specific eBay marketplace, that is returned by the <b> initiateGuestCheckoutSession</b> method.<br /><br /><span class=\"tablenote\"><b>Note:</b> When using this ID, the X-EBAY-C-MARKETPLACE-ID value and developer App ID must be the same as that used when this guest checkout session was created. See <a href=\"/api-docs/buy/order/overview.html#checkout-restriction\">Checkout session restrictions</a> in the Buy Integration Guide for details.</span> (required)
* @param string $x_ebay_c_marketplace_id A header that identifies the user's business context and is specified using a marketplace ID value.<br /><br /><span class=\"tablenote\"><b>Note:</b> This header does <i>not</i> indicate a language preference or consumer location.</span><br /><br />See <a href=\"/api-docs/static/rest-request-components.html#marketpl\" target=\"_blank\">Marketplace ID values</a> for a list of supported values. (required)
* @param \TNT\Ebay\Buy\Order\V2\Model\CouponRequest $coupon_request The container for the fields used by the <b>removeGuestCoupon</b> method. (optional)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Psr7\Request
*/
public function removeGuestCouponRequest($checkout_session_id, $x_ebay_c_marketplace_id, $coupon_request = null)
{
// Verify the required parameter 'checkout_session_id' is set.
if ($checkout_session_id === null || (\is_array($checkout_session_id) && count($checkout_session_id) === 0)) {
throw new \InvalidArgumentException('Missing the required parameter $checkout_session_id when calling removeGuestCoupon');
}
// Verify the required parameter 'x_ebay_c_marketplace_id' is set.
if ($x_ebay_c_marketplace_id === null || (\is_array($x_ebay_c_marketplace_id) && count($x_ebay_c_marketplace_id) === 0)) {
throw new \InvalidArgumentException('Missing the required parameter $x_ebay_c_marketplace_id when calling removeGuestCoupon');
}
$resourcePath = '/guest_checkout_session/{checkoutSessionId}/remove_coupon';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($x_ebay_c_marketplace_id !== null) {
$headerParams['X-EBAY-C-MARKETPLACE-ID'] = ObjectSerializer::toHeaderValue($x_ebay_c_marketplace_id);
}
// path params
if ($checkout_session_id !== null) {
$resourcePath = str_replace(
'{checkoutSessionId}',
ObjectSerializer::toPathValue($checkout_session_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($coupon_request)) {
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($coupon_request));
} else {
$httpBody = $coupon_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();
}
$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 updateGuestQuantity.
*
* @param string $checkout_session_id The eBay-assigned session ID, for a specific eBay marketplace, that is returned by the <b> initiateGuestCheckoutSession</b> method.<br /><br /><span class=\"tablenote\"><b>Note:</b> When using this ID, the X-EBAY-C-MARKETPLACE-ID value and developer App ID must be the same as that used when this guest checkout session was created. See <a href=\"/api-docs/buy/order/overview.html#checkout-restriction\">Checkout session restrictions</a> in the Buy Integration Guide for details.</span> (required)
* @param string $x_ebay_c_marketplace_id A header that identifies the user's business context and is specified using a marketplace ID value.<br /><br /><span class=\"tablenote\"><b>Note:</b> This header does <i>not</i> indicate a language preference or consumer location.</span><br /><br />See <a href=\"/api-docs/static/rest-request-components.html#marketpl\" target=\"_blank\">Marketplace ID values</a> for a list of supported values. (required)
* @param \TNT\Ebay\Buy\Order\V2\Model\UpdateQuantity $update_quantity The container for the fields used by the <b>updateGuestQuantity</b> method. (optional)
*
* @throws \TNT\Ebay\Buy\Order\V2\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return \TNT\Ebay\Buy\Order\V2\Model\GuestCheckoutSessionResponseV2
*/
public function updateGuestQuantity($checkout_session_id, $x_ebay_c_marketplace_id, $update_quantity = null)
{
[$response] = $this->updateGuestQuantityWithHttpInfo($checkout_session_id, $x_ebay_c_marketplace_id, $update_quantity);
return $response;
}
/**
* Operation updateGuestQuantityWithHttpInfo.
*
* @param string $checkout_session_id The eBay-assigned session ID, for a specific eBay marketplace, that is returned by the <b> initiateGuestCheckoutSession</b> method.<br /><br /><span class=\"tablenote\"><b>Note:</b> When using this ID, the X-EBAY-C-MARKETPLACE-ID value and developer App ID must be the same as that used when this guest checkout session was created. See <a href=\"/api-docs/buy/order/overview.html#checkout-restriction\">Checkout session restrictions</a> in the Buy Integration Guide for details.</span> (required)
* @param string $x_ebay_c_marketplace_id A header that identifies the user's business context and is specified using a marketplace ID value.<br /><br /><span class=\"tablenote\"><b>Note:</b> This header does <i>not</i> indicate a language preference or consumer location.</span><br /><br />See <a href=\"/api-docs/static/rest-request-components.html#marketpl\" target=\"_blank\">Marketplace ID values</a> for a list of supported values. (required)
* @param \TNT\Ebay\Buy\Order\V2\Model\UpdateQuantity $update_quantity The container for the fields used by the <b>updateGuestQuantity</b> method. (optional)
*
* @throws \TNT\Ebay\Buy\Order\V2\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return array of \TNT\Ebay\Buy\Order\V2\Model\GuestCheckoutSessionResponseV2, HTTP status code, HTTP response headers (array of strings)
*/
public function updateGuestQuantityWithHttpInfo($checkout_session_id, $x_ebay_c_marketplace_id, $update_quantity = null)
{
$request = $this->updateGuestQuantityRequest($checkout_session_id, $x_ebay_c_marketplace_id, $update_quantity);
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\Buy\Order\V2\Model\GuestCheckoutSessionResponseV2' === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, '\TNT\Ebay\Buy\Order\V2\Model\GuestCheckoutSessionResponseV2', []),
$response->getStatusCode(),
$response->getHeaders(),
];
}
$returnType = '\TNT\Ebay\Buy\Order\V2\Model\GuestCheckoutSessionResponseV2';
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\Buy\Order\V2\Model\GuestCheckoutSessionResponseV2',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation updateGuestQuantityAsync.
*
* @param string $checkout_session_id The eBay-assigned session ID, for a specific eBay marketplace, that is returned by the <b> initiateGuestCheckoutSession</b> method.<br /><br /><span class=\"tablenote\"><b>Note:</b> When using this ID, the X-EBAY-C-MARKETPLACE-ID value and developer App ID must be the same as that used when this guest checkout session was created. See <a href=\"/api-docs/buy/order/overview.html#checkout-restriction\">Checkout session restrictions</a> in the Buy Integration Guide for details.</span> (required)
* @param string $x_ebay_c_marketplace_id A header that identifies the user's business context and is specified using a marketplace ID value.<br /><br /><span class=\"tablenote\"><b>Note:</b> This header does <i>not</i> indicate a language preference or consumer location.</span><br /><br />See <a href=\"/api-docs/static/rest-request-components.html#marketpl\" target=\"_blank\">Marketplace ID values</a> for a list of supported values. (required)
* @param \TNT\Ebay\Buy\Order\V2\Model\UpdateQuantity $update_quantity The container for the fields used by the <b>updateGuestQuantity</b> method. (optional)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateGuestQuantityAsync($checkout_session_id, $x_ebay_c_marketplace_id, $update_quantity = null)
{
return $this->updateGuestQuantityAsyncWithHttpInfo($checkout_session_id, $x_ebay_c_marketplace_id, $update_quantity)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation updateGuestQuantityAsyncWithHttpInfo.
*
* @param string $checkout_session_id The eBay-assigned session ID, for a specific eBay marketplace, that is returned by the <b> initiateGuestCheckoutSession</b> method.<br /><br /><span class=\"tablenote\"><b>Note:</b> When using this ID, the X-EBAY-C-MARKETPLACE-ID value and developer App ID must be the same as that used when this guest checkout session was created. See <a href=\"/api-docs/buy/order/overview.html#checkout-restriction\">Checkout session restrictions</a> in the Buy Integration Guide for details.</span> (required)
* @param string $x_ebay_c_marketplace_id A header that identifies the user's business context and is specified using a marketplace ID value.<br /><br /><span class=\"tablenote\"><b>Note:</b> This header does <i>not</i> indicate a language preference or consumer location.</span><br /><br />See <a href=\"/api-docs/static/rest-request-components.html#marketpl\" target=\"_blank\">Marketplace ID values</a> for a list of supported values. (required)
* @param \TNT\Ebay\Buy\Order\V2\Model\UpdateQuantity $update_quantity The container for the fields used by the <b>updateGuestQuantity</b> method. (optional)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateGuestQuantityAsyncWithHttpInfo($checkout_session_id, $x_ebay_c_marketplace_id, $update_quantity = null)
{
$returnType = '\TNT\Ebay\Buy\Order\V2\Model\GuestCheckoutSessionResponseV2';
$request = $this->updateGuestQuantityRequest($checkout_session_id, $x_ebay_c_marketplace_id, $update_quantity);
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 'updateGuestQuantity'.
*
* @param string $checkout_session_id The eBay-assigned session ID, for a specific eBay marketplace, that is returned by the <b> initiateGuestCheckoutSession</b> method.<br /><br /><span class=\"tablenote\"><b>Note:</b> When using this ID, the X-EBAY-C-MARKETPLACE-ID value and developer App ID must be the same as that used when this guest checkout session was created. See <a href=\"/api-docs/buy/order/overview.html#checkout-restriction\">Checkout session restrictions</a> in the Buy Integration Guide for details.</span> (required)
* @param string $x_ebay_c_marketplace_id A header that identifies the user's business context and is specified using a marketplace ID value.<br /><br /><span class=\"tablenote\"><b>Note:</b> This header does <i>not</i> indicate a language preference or consumer location.</span><br /><br />See <a href=\"/api-docs/static/rest-request-components.html#marketpl\" target=\"_blank\">Marketplace ID values</a> for a list of supported values. (required)
* @param \TNT\Ebay\Buy\Order\V2\Model\UpdateQuantity $update_quantity The container for the fields used by the <b>updateGuestQuantity</b> method. (optional)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Psr7\Request
*/
public function updateGuestQuantityRequest($checkout_session_id, $x_ebay_c_marketplace_id, $update_quantity = null)
{
// Verify the required parameter 'checkout_session_id' is set.
if ($checkout_session_id === null || (\is_array($checkout_session_id) && count($checkout_session_id) === 0)) {
throw new \InvalidArgumentException('Missing the required parameter $checkout_session_id when calling updateGuestQuantity');
}
// Verify the required parameter 'x_ebay_c_marketplace_id' is set.
if ($x_ebay_c_marketplace_id === null || (\is_array($x_ebay_c_marketplace_id) && count($x_ebay_c_marketplace_id) === 0)) {
throw new \InvalidArgumentException('Missing the required parameter $x_ebay_c_marketplace_id when calling updateGuestQuantity');
}
$resourcePath = '/guest_checkout_session/{checkoutSessionId}/update_quantity';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($x_ebay_c_marketplace_id !== null) {
$headerParams['X-EBAY-C-MARKETPLACE-ID'] = ObjectSerializer::toHeaderValue($x_ebay_c_marketplace_id);
}
// path params
if ($checkout_session_id !== null) {
$resourcePath = str_replace(
'{checkoutSessionId}',
ObjectSerializer::toPathValue($checkout_session_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($update_quantity)) {
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($update_quantity));
} else {
$httpBody = $update_quantity;
}
} 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();
}
$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 updateGuestShippingAddress.
*
* @param string $checkout_session_id The eBay-assigned session ID, for a specific eBay marketplace, that is returned by the <b> initiateGuestCheckoutSession</b> method.<br /><br /><span class=\"tablenote\"><b>Note:</b> When using this ID, the X-EBAY-C-MARKETPLACE-ID value and developer App ID must be the same as that used when this guest checkout session was created. See <a href=\"/api-docs/buy/order/overview.html#checkout-restriction\">Checkout session restrictions</a> in the Buy Integration Guide for details.</span> (required)
* @param string $x_ebay_c_marketplace_id A header that identifies the user's business context and is specified using a marketplace ID value.<br /><br /><span class=\"tablenote\"><b>Note:</b> This header does <i>not</i> indicate a language preference or consumer location.</span><br /><br />See <a href=\"/api-docs/static/rest-request-components.html#marketpl\" target=\"_blank\">Marketplace ID values</a> for a list of supported values. (required)
* @param \TNT\Ebay\Buy\Order\V2\Model\ShippingAddressImpl $shipping_address_impl The container for the fields used by the <b>updateGuestShippingAddress</b> method. (optional)
*
* @throws \TNT\Ebay\Buy\Order\V2\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return \TNT\Ebay\Buy\Order\V2\Model\GuestCheckoutSessionResponseV2
*/
public function updateGuestShippingAddress($checkout_session_id, $x_ebay_c_marketplace_id, $shipping_address_impl = null)
{
[$response] = $this->updateGuestShippingAddressWithHttpInfo($checkout_session_id, $x_ebay_c_marketplace_id, $shipping_address_impl);
return $response;
}
/**
* Operation updateGuestShippingAddressWithHttpInfo.
*
* @param string $checkout_session_id The eBay-assigned session ID, for a specific eBay marketplace, that is returned by the <b> initiateGuestCheckoutSession</b> method.<br /><br /><span class=\"tablenote\"><b>Note:</b> When using this ID, the X-EBAY-C-MARKETPLACE-ID value and developer App ID must be the same as that used when this guest checkout session was created. See <a href=\"/api-docs/buy/order/overview.html#checkout-restriction\">Checkout session restrictions</a> in the Buy Integration Guide for details.</span> (required)
* @param string $x_ebay_c_marketplace_id A header that identifies the user's business context and is specified using a marketplace ID value.<br /><br /><span class=\"tablenote\"><b>Note:</b> This header does <i>not</i> indicate a language preference or consumer location.</span><br /><br />See <a href=\"/api-docs/static/rest-request-components.html#marketpl\" target=\"_blank\">Marketplace ID values</a> for a list of supported values. (required)
* @param \TNT\Ebay\Buy\Order\V2\Model\ShippingAddressImpl $shipping_address_impl The container for the fields used by the <b>updateGuestShippingAddress</b> method. (optional)
*
* @throws \TNT\Ebay\Buy\Order\V2\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return array of \TNT\Ebay\Buy\Order\V2\Model\GuestCheckoutSessionResponseV2, HTTP status code, HTTP response headers (array of strings)
*/
public function updateGuestShippingAddressWithHttpInfo($checkout_session_id, $x_ebay_c_marketplace_id, $shipping_address_impl = null)
{
$request = $this->updateGuestShippingAddressRequest($checkout_session_id, $x_ebay_c_marketplace_id, $shipping_address_impl);
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\Buy\Order\V2\Model\GuestCheckoutSessionResponseV2' === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, '\TNT\Ebay\Buy\Order\V2\Model\GuestCheckoutSessionResponseV2', []),
$response->getStatusCode(),
$response->getHeaders(),
];
}
$returnType = '\TNT\Ebay\Buy\Order\V2\Model\GuestCheckoutSessionResponseV2';
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\Buy\Order\V2\Model\GuestCheckoutSessionResponseV2',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation updateGuestShippingAddressAsync.
*
* @param string $checkout_session_id The eBay-assigned session ID, for a specific eBay marketplace, that is returned by the <b> initiateGuestCheckoutSession</b> method.<br /><br /><span class=\"tablenote\"><b>Note:</b> When using this ID, the X-EBAY-C-MARKETPLACE-ID value and developer App ID must be the same as that used when this guest checkout session was created. See <a href=\"/api-docs/buy/order/overview.html#checkout-restriction\">Checkout session restrictions</a> in the Buy Integration Guide for details.</span> (required)
* @param string $x_ebay_c_marketplace_id A header that identifies the user's business context and is specified using a marketplace ID value.<br /><br /><span class=\"tablenote\"><b>Note:</b> This header does <i>not</i> indicate a language preference or consumer location.</span><br /><br />See <a href=\"/api-docs/static/rest-request-components.html#marketpl\" target=\"_blank\">Marketplace ID values</a> for a list of supported values. (required)
* @param \TNT\Ebay\Buy\Order\V2\Model\ShippingAddressImpl $shipping_address_impl The container for the fields used by the <b>updateGuestShippingAddress</b> method. (optional)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateGuestShippingAddressAsync($checkout_session_id, $x_ebay_c_marketplace_id, $shipping_address_impl = null)
{
return $this->updateGuestShippingAddressAsyncWithHttpInfo($checkout_session_id, $x_ebay_c_marketplace_id, $shipping_address_impl)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation updateGuestShippingAddressAsyncWithHttpInfo.
*
* @param string $checkout_session_id The eBay-assigned session ID, for a specific eBay marketplace, that is returned by the <b> initiateGuestCheckoutSession</b> method.<br /><br /><span class=\"tablenote\"><b>Note:</b> When using this ID, the X-EBAY-C-MARKETPLACE-ID value and developer App ID must be the same as that used when this guest checkout session was created. See <a href=\"/api-docs/buy/order/overview.html#checkout-restriction\">Checkout session restrictions</a> in the Buy Integration Guide for details.</span> (required)
* @param string $x_ebay_c_marketplace_id A header that identifies the user's business context and is specified using a marketplace ID value.<br /><br /><span class=\"tablenote\"><b>Note:</b> This header does <i>not</i> indicate a language preference or consumer location.</span><br /><br />See <a href=\"/api-docs/static/rest-request-components.html#marketpl\" target=\"_blank\">Marketplace ID values</a> for a list of supported values. (required)
* @param \TNT\Ebay\Buy\Order\V2\Model\ShippingAddressImpl $shipping_address_impl The container for the fields used by the <b>updateGuestShippingAddress</b> method. (optional)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateGuestShippingAddressAsyncWithHttpInfo($checkout_session_id, $x_ebay_c_marketplace_id, $shipping_address_impl = null)
{
$returnType = '\TNT\Ebay\Buy\Order\V2\Model\GuestCheckoutSessionResponseV2';
$request = $this->updateGuestShippingAddressRequest($checkout_session_id, $x_ebay_c_marketplace_id, $shipping_address_impl);
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 'updateGuestShippingAddress'.
*
* @param string $checkout_session_id The eBay-assigned session ID, for a specific eBay marketplace, that is returned by the <b> initiateGuestCheckoutSession</b> method.<br /><br /><span class=\"tablenote\"><b>Note:</b> When using this ID, the X-EBAY-C-MARKETPLACE-ID value and developer App ID must be the same as that used when this guest checkout session was created. See <a href=\"/api-docs/buy/order/overview.html#checkout-restriction\">Checkout session restrictions</a> in the Buy Integration Guide for details.</span> (required)
* @param string $x_ebay_c_marketplace_id A header that identifies the user's business context and is specified using a marketplace ID value.<br /><br /><span class=\"tablenote\"><b>Note:</b> This header does <i>not</i> indicate a language preference or consumer location.</span><br /><br />See <a href=\"/api-docs/static/rest-request-components.html#marketpl\" target=\"_blank\">Marketplace ID values</a> for a list of supported values. (required)
* @param \TNT\Ebay\Buy\Order\V2\Model\ShippingAddressImpl $shipping_address_impl The container for the fields used by the <b>updateGuestShippingAddress</b> method. (optional)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Psr7\Request
*/
public function updateGuestShippingAddressRequest($checkout_session_id, $x_ebay_c_marketplace_id, $shipping_address_impl = null)
{
// Verify the required parameter 'checkout_session_id' is set.
if ($checkout_session_id === null || (\is_array($checkout_session_id) && count($checkout_session_id) === 0)) {
throw new \InvalidArgumentException('Missing the required parameter $checkout_session_id when calling updateGuestShippingAddress');
}
// Verify the required parameter 'x_ebay_c_marketplace_id' is set.
if ($x_ebay_c_marketplace_id === null || (\is_array($x_ebay_c_marketplace_id) && count($x_ebay_c_marketplace_id) === 0)) {
throw new \InvalidArgumentException('Missing the required parameter $x_ebay_c_marketplace_id when calling updateGuestShippingAddress');
}
$resourcePath = '/guest_checkout_session/{checkoutSessionId}/update_shipping_address';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($x_ebay_c_marketplace_id !== null) {
$headerParams['X-EBAY-C-MARKETPLACE-ID'] = ObjectSerializer::toHeaderValue($x_ebay_c_marketplace_id);
}
// path params
if ($checkout_session_id !== null) {
$resourcePath = str_replace(
'{checkoutSessionId}',
ObjectSerializer::toPathValue($checkout_session_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($shipping_address_impl)) {
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($shipping_address_impl));
} else {
$httpBody = $shipping_address_impl;
}
} 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();
}
$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 updateGuestShippingOption.
*
* @param string $checkout_session_id The eBay-assigned session ID, for a specific eBay marketplace, that is returned by the <b> initiateGuestCheckoutSession</b> method.<br /><br /><span class=\"tablenote\"><b>Note:</b> When using this ID, the X-EBAY-C-MARKETPLACE-ID value and developer App ID must be the same as that used when this guest checkout session was created. See <a href=\"/api-docs/buy/order/overview.html#checkout-restriction\">Checkout session restrictions</a> in the Buy Integration Guide for details.</span> (required)
* @param string $x_ebay_c_marketplace_id A header that identifies the user's business context and is specified using a marketplace ID value.<br /><br /><span class=\"tablenote\"><b>Note:</b> This header does <i>not</i> indicate a language preference or consumer location.</span><br /><br />See <a href=\"/api-docs/static/rest-request-components.html#marketpl\" target=\"_blank\">Marketplace ID values</a> for a list of supported values. (required)
* @param \TNT\Ebay\Buy\Order\V2\Model\UpdateShippingOption $update_shipping_option The container for the fields used by the <b>updateGuestShippingOption</b> method. (optional)
*
* @throws \TNT\Ebay\Buy\Order\V2\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return \TNT\Ebay\Buy\Order\V2\Model\GuestCheckoutSessionResponseV2
*/
public function updateGuestShippingOption($checkout_session_id, $x_ebay_c_marketplace_id, $update_shipping_option = null)
{
[$response] = $this->updateGuestShippingOptionWithHttpInfo($checkout_session_id, $x_ebay_c_marketplace_id, $update_shipping_option);
return $response;
}
/**
* Operation updateGuestShippingOptionWithHttpInfo.
*
* @param string $checkout_session_id The eBay-assigned session ID, for a specific eBay marketplace, that is returned by the <b> initiateGuestCheckoutSession</b> method.<br /><br /><span class=\"tablenote\"><b>Note:</b> When using this ID, the X-EBAY-C-MARKETPLACE-ID value and developer App ID must be the same as that used when this guest checkout session was created. See <a href=\"/api-docs/buy/order/overview.html#checkout-restriction\">Checkout session restrictions</a> in the Buy Integration Guide for details.</span> (required)
* @param string $x_ebay_c_marketplace_id A header that identifies the user's business context and is specified using a marketplace ID value.<br /><br /><span class=\"tablenote\"><b>Note:</b> This header does <i>not</i> indicate a language preference or consumer location.</span><br /><br />See <a href=\"/api-docs/static/rest-request-components.html#marketpl\" target=\"_blank\">Marketplace ID values</a> for a list of supported values. (required)
* @param \TNT\Ebay\Buy\Order\V2\Model\UpdateShippingOption $update_shipping_option The container for the fields used by the <b>updateGuestShippingOption</b> method. (optional)
*
* @throws \TNT\Ebay\Buy\Order\V2\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return array of \TNT\Ebay\Buy\Order\V2\Model\GuestCheckoutSessionResponseV2, HTTP status code, HTTP response headers (array of strings)
*/
public function updateGuestShippingOptionWithHttpInfo($checkout_session_id, $x_ebay_c_marketplace_id, $update_shipping_option = null)
{
$request = $this->updateGuestShippingOptionRequest($checkout_session_id, $x_ebay_c_marketplace_id, $update_shipping_option);
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\Buy\Order\V2\Model\GuestCheckoutSessionResponseV2' === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, '\TNT\Ebay\Buy\Order\V2\Model\GuestCheckoutSessionResponseV2', []),
$response->getStatusCode(),
$response->getHeaders(),
];
}
$returnType = '\TNT\Ebay\Buy\Order\V2\Model\GuestCheckoutSessionResponseV2';
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\Buy\Order\V2\Model\GuestCheckoutSessionResponseV2',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation updateGuestShippingOptionAsync.
*
* @param string $checkout_session_id The eBay-assigned session ID, for a specific eBay marketplace, that is returned by the <b> initiateGuestCheckoutSession</b> method.<br /><br /><span class=\"tablenote\"><b>Note:</b> When using this ID, the X-EBAY-C-MARKETPLACE-ID value and developer App ID must be the same as that used when this guest checkout session was created. See <a href=\"/api-docs/buy/order/overview.html#checkout-restriction\">Checkout session restrictions</a> in the Buy Integration Guide for details.</span> (required)
* @param string $x_ebay_c_marketplace_id A header that identifies the user's business context and is specified using a marketplace ID value.<br /><br /><span class=\"tablenote\"><b>Note:</b> This header does <i>not</i> indicate a language preference or consumer location.</span><br /><br />See <a href=\"/api-docs/static/rest-request-components.html#marketpl\" target=\"_blank\">Marketplace ID values</a> for a list of supported values. (required)
* @param \TNT\Ebay\Buy\Order\V2\Model\UpdateShippingOption $update_shipping_option The container for the fields used by the <b>updateGuestShippingOption</b> method. (optional)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateGuestShippingOptionAsync($checkout_session_id, $x_ebay_c_marketplace_id, $update_shipping_option = null)
{
return $this->updateGuestShippingOptionAsyncWithHttpInfo($checkout_session_id, $x_ebay_c_marketplace_id, $update_shipping_option)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation updateGuestShippingOptionAsyncWithHttpInfo.
*
* @param string $checkout_session_id The eBay-assigned session ID, for a specific eBay marketplace, that is returned by the <b> initiateGuestCheckoutSession</b> method.<br /><br /><span class=\"tablenote\"><b>Note:</b> When using this ID, the X-EBAY-C-MARKETPLACE-ID value and developer App ID must be the same as that used when this guest checkout session was created. See <a href=\"/api-docs/buy/order/overview.html#checkout-restriction\">Checkout session restrictions</a> in the Buy Integration Guide for details.</span> (required)
* @param string $x_ebay_c_marketplace_id A header that identifies the user's business context and is specified using a marketplace ID value.<br /><br /><span class=\"tablenote\"><b>Note:</b> This header does <i>not</i> indicate a language preference or consumer location.</span><br /><br />See <a href=\"/api-docs/static/rest-request-components.html#marketpl\" target=\"_blank\">Marketplace ID values</a> for a list of supported values. (required)
* @param \TNT\Ebay\Buy\Order\V2\Model\UpdateShippingOption $update_shipping_option The container for the fields used by the <b>updateGuestShippingOption</b> method. (optional)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateGuestShippingOptionAsyncWithHttpInfo($checkout_session_id, $x_ebay_c_marketplace_id, $update_shipping_option = null)
{
$returnType = '\TNT\Ebay\Buy\Order\V2\Model\GuestCheckoutSessionResponseV2';
$request = $this->updateGuestShippingOptionRequest($checkout_session_id, $x_ebay_c_marketplace_id, $update_shipping_option);
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 'updateGuestShippingOption'.
*
* @param string $checkout_session_id The eBay-assigned session ID, for a specific eBay marketplace, that is returned by the <b> initiateGuestCheckoutSession</b> method.<br /><br /><span class=\"tablenote\"><b>Note:</b> When using this ID, the X-EBAY-C-MARKETPLACE-ID value and developer App ID must be the same as that used when this guest checkout session was created. See <a href=\"/api-docs/buy/order/overview.html#checkout-restriction\">Checkout session restrictions</a> in the Buy Integration Guide for details.</span> (required)
* @param string $x_ebay_c_marketplace_id A header that identifies the user's business context and is specified using a marketplace ID value.<br /><br /><span class=\"tablenote\"><b>Note:</b> This header does <i>not</i> indicate a language preference or consumer location.</span><br /><br />See <a href=\"/api-docs/static/rest-request-components.html#marketpl\" target=\"_blank\">Marketplace ID values</a> for a list of supported values. (required)
* @param \TNT\Ebay\Buy\Order\V2\Model\UpdateShippingOption $update_shipping_option The container for the fields used by the <b>updateGuestShippingOption</b> method. (optional)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Psr7\Request
*/
public function updateGuestShippingOptionRequest($checkout_session_id, $x_ebay_c_marketplace_id, $update_shipping_option = null)
{
// Verify the required parameter 'checkout_session_id' is set.
if ($checkout_session_id === null || (\is_array($checkout_session_id) && count($checkout_session_id) === 0)) {
throw new \InvalidArgumentException('Missing the required parameter $checkout_session_id when calling updateGuestShippingOption');
}
// Verify the required parameter 'x_ebay_c_marketplace_id' is set.
if ($x_ebay_c_marketplace_id === null || (\is_array($x_ebay_c_marketplace_id) && count($x_ebay_c_marketplace_id) === 0)) {
throw new \InvalidArgumentException('Missing the required parameter $x_ebay_c_marketplace_id when calling updateGuestShippingOption');
}
$resourcePath = '/guest_checkout_session/{checkoutSessionId}/update_shipping_option';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($x_ebay_c_marketplace_id !== null) {
$headerParams['X-EBAY-C-MARKETPLACE-ID'] = ObjectSerializer::toHeaderValue($x_ebay_c_marketplace_id);
}
// path params
if ($checkout_session_id !== null) {
$resourcePath = str_replace(
'{checkoutSessionId}',
ObjectSerializer::toPathValue($checkout_session_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($update_shipping_option)) {
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($update_shipping_option));
} else {
$httpBody = $update_shipping_option;
}
} 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();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = ObjectSerializer::buildQuery($queryParams);
return new Request(
'POST',
$this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Create http client option.
*
* @throws \RuntimeException on file opening failure
*
* @return array of http client options
*/
protected function createHttpClientOption()
{
$options = [];
if ($this->config->getDebug()) {
$options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'ab');
if (! $options[RequestOptions::DEBUG]) {
throw new \RuntimeException('Failed to open the debug file: '.$this->config->getDebugFile());
}
}
return $options;
}
}