<?php

namespace Tops\AmazonSellingPartnerAPI\Api;

class ListingsItemsApi20210801 extends BaseApi
{
    /**
     * Operation List Catalog Items
     *
     * @param array $params
     * @param string $params['MarketplaceId'] A marketplace identifier. Specifies the marketplace for which items are returned. (required)
     * @param string $params['Query'] Keyword(s) to use to search for items in the catalog. Example: 'harry potter books'.
     * @param string $params['QueryContextId'] An identifier for the context within which the given search will be performed. A marketplace might provide mechanisms for constraining a search to a subset of potential items. For example, the retail marketplace allows queries to be constrained to a specific category. The QueryContextId parameter specifies such a subset. If it is omitted, the search will be performed using the default context for the marketplace, which will typically contain the largest set of items.
     * @param string $params['SellerSKU'] Used to identify an item in the given marketplace. SellerSKU is qualified by the seller's SellerId, which is included with every operation that you submit.
     * @param string $params['UPC'] A 12-digit bar code used for retail packaging.
     * @param string $params['EAN'] A European article number that uniquely identifies the catalog item, manufacturer, and its attributes.
     * @param string $params['ISBN'] The unique commercial book identifier used to identify books internationally.
     * @param string $params['JAN'] A Japanese article number that uniquely identifies the product, manufacturer, and its attributes.
     * @return json\
     *
     * @author Chetan Meena <chetan@topsinfosolutions.com>
     *
     * about more Ref: https://github.com/amzn/selling-partner-api-docs/blob/main/references/catalog-items-api/catalogItemsV0.md#listcatalogitems
     */
    public function getListingsItem($params, $seller_id, $sku)
    {
        if (null === $seller_id) {
            throw new \InvalidArgumentException('Missing the required parameter $seller_id when calling getListingsItem');
        }
        if (null === $sku) {
            throw new \InvalidArgumentException('Missing the required parameter $sku when calling getListingsItem');
        }
        if (!array_key_exists('marketplaceIds', $params) ||  null === $params['marketplaceIds']) {
            throw new \InvalidArgumentException('Missing the required parameter $marketplaceIds when calling getListingsItem');
        }

        $resource_path = '/listings/2021-08-01/items/{sellerId}/{sku}';
        $url = $this->config->getHost() . $resource_path;
        $http_body = '';
        $query_params = [];
        $method = 'GET';

        // path params
        if (null !== $seller_id) {
            $resource_path = str_replace(
                '{' . 'sellerId' . '}',
                $seller_id,
                $resource_path
            );
        }
        if (null !== $sku) {
            $resource_path = str_replace(
                '{' . 'sku' . '}',
                $sku,
                $resource_path
            );
        }

        // query params
        if (array_key_exists('marketplaceIds', $params) && $params['marketplaceIds'] !== null) {
            $query_params['marketplaceIds'] = $params['marketplaceIds'];
        }
        if (array_key_exists('issueLocale', $params) && $params['issueLocale'] !== null) {
            $query_params['issueLocale'] = $params['issueLocale'];
        }
        if (array_key_exists('includedData', $params) && $params['includedData'] !== null) {
            $query_params['includedData'] = $params['includedData'];
        }

        $curl_headers = $this->generateRequest($resource_path, $query_params, $http_body, $this->config, $method);

        return $this->sendRequest($url, $query_params, $http_body, $curl_headers, $method);
    }
    /**
     * Operation List Catalog Items
     *
     * @param array $params
     * @param string $params['MarketplaceId'] A marketplace identifier. Specifies the marketplace for which items are returned. (required)
     * @param string $params['Query'] Keyword(s) to use to search for items in the catalog. Example: 'harry potter books'.
     * @param string $params['QueryContextId'] An identifier for the context within which the given search will be performed. A marketplace might provide mechanisms for constraining a search to a subset of potential items. For example, the retail marketplace allows queries to be constrained to a specific category. The QueryContextId parameter specifies such a subset. If it is omitted, the search will be performed using the default context for the marketplace, which will typically contain the largest set of items.
     * @param string $params['SellerSKU'] Used to identify an item in the given marketplace. SellerSKU is qualified by the seller's SellerId, which is included with every operation that you submit.
     * @param string $params['UPC'] A 12-digit bar code used for retail packaging.
     * @param string $params['EAN'] A European article number that uniquely identifies the catalog item, manufacturer, and its attributes.
     * @param string $params['ISBN'] The unique commercial book identifier used to identify books internationally.
     * @param string $params['JAN'] A Japanese article number that uniquely identifies the product, manufacturer, and its attributes.
     * @return json\
     *
     * @author Chetan Meena <chetan@topsinfosolutions.com>
     *
     * about more Ref: https://github.com/amzn/selling-partner-api-docs/blob/main/references/catalog-items-api/catalogItemsV0.md#listcatalogitems
     */
    public function putListingsItem($body, $params, $seller_id, $sku)
    {
        if (null === $seller_id) {
            throw new \InvalidArgumentException('Missing the required parameter $seller_id when calling putListingsItem');
        }
        if (null === $sku) {
            throw new \InvalidArgumentException('Missing the required parameter $sku when calling putListingsItem');
        }
        if (null === $body) {
            throw new \InvalidArgumentException('Missing the required parameter $body when calling putListingsItem');
        }
        if (!array_key_exists('marketplaceIds', $params) ||  null === $params['marketplaceIds']) {
            throw new \InvalidArgumentException('Missing the required parameter $marketplaceIds when calling putListingsItem');
        }

        $resource_path = '/listings/2021-08-01/items/{sellerId}/{sku}';
        $url = $this->config->getHost() . $resource_path;
        $http_body = $body;
        $query_params = [];
        $method = 'PUT';

        // path params
        if (null !== $seller_id) {
            $resource_path = str_replace(
                '{' . 'sellerId' . '}',
                $seller_id,
                $resource_path
            );
        }
        if (null !== $sku) {
            $resource_path = str_replace(
                '{' . 'sku' . '}',
                $sku,
                $resource_path
            );
        }

        // query params
        if (array_key_exists('marketplaceIds', $params) && $params['marketplaceIds'] !== null) {
            $query_params['marketplaceIds'] = $params['marketplaceIds'];
        }
        if (array_key_exists('issueLocale', $params) && $params['issueLocale'] !== null) {
            $query_params['issueLocale'] = $params['issueLocale'];
        }

        $curl_headers = $this->generateRequest($resource_path, $query_params, $http_body, $this->config, $method);

        return $this->sendRequest($url, $query_params, $http_body, $curl_headers, $method);
    }

    /**
     * Operation Get Catalog Item
     *
     * @param array $params
     * @param string $params['MarketplaceIds'] A marketplace identifier. Specifies the marketplace for the item. (required)
     * @param string $asin The Amazon Standard Identification Number (ASIN) of the item. (required)
     * @return json\
     *
     * @author Chetan Meena <chetan@topsinfosolutions.com>
     *
     * about more Ref: https://github.com/amzn/selling-partner-api-docs/blob/main/references/catalog-items-api/catalogItemsV0.md#getcatalogitem
     */
    public function deleteListingsItem($params, $seller_id, $sku)
    {
        if (null === $seller_id) {
            throw new \InvalidArgumentException('Missing the required parameter $seller_id when calling deleteListingsItem');
        }
        if (null === $sku) {
            throw new \InvalidArgumentException('Missing the required parameter $sku when calling deleteListingsItem');
        }
        if (!array_key_exists('marketplaceIds', $params) ||  null === $params['marketplaceIds']) {
            throw new \InvalidArgumentException('Missing the required parameter $marketplaceIds when calling deleteListingsItem');
        }

        $resource_path = '/listings/2021-08-01/items/{sellerId}/{sku}';
        $http_body = '';
        $query_params = [];
        $method = 'DELETE';

        // query params
        if (array_key_exists('marketplaceIds', $params) && $params['marketplaceIds'] !== null) {
            $query_params['marketplaceIds'] = is_array($params['marketplaceIds']) ? implode(',', $params['marketplaceIds']) :  $params['marketplaceIds'];
        }
        if (array_key_exists('issueLocale', $params) && $params['issueLocale'] !== null) {
            $query_params['issueLocale'] = is_array($params['issueLocale']) ? implode(',', $params['issueLocale']) :  $params['issueLocale'];
        }

        // path params
        if (null !== $sku) {
            $resource_path = str_replace(
                '{' . 'sku' . '}',
                rawurlencode($sku),
                $resource_path
            );
        }
        if (null !== $seller_id) {
            $resource_path = str_replace(
                '{' . 'sellerId' . '}',
                rawurlencode($seller_id),
                $resource_path
            );
        }

        $curl_headers = $this->generateRequest($resource_path, $query_params, $http_body, $this->config, $method);
        $url = $this->config->getHost() . $resource_path;

        return $this->sendRequest($url, $query_params, $http_body, $curl_headers, $method);
    }

    /**
     * Operation List Catalog Categories
     *
     * @param array $params
     * @param string $params['MarketplaceId'] A marketplace identifier. Specifies the marketplace for the item. (required)
     * @param string $params['ASIN'] The Amazon Standard Identification Number (ASIN) of the item.
     * @param string $params['SellerSKU'] Used to identify items in the given marketplace. SellerSKU is qualified by the seller's SellerId, which is included with every operation that you submit.
     *
     * @return json\
     *
     * @author Chetan Meena <chetan@topsinfosolutions.com>
     *
     *  about more Ref: https://github.com/amzn/selling-partner-api-docs/blob/main/references/catalog-items-api/catalogItemsV0.md#listcatalogcategories
     */
    public function patchListingsItem($body, $params, $seller_id, $sku)
    {
        if (null === $seller_id) {
            throw new \InvalidArgumentException('Missing the required parameter $seller_id when calling patchListingsItem');
        }
        if (null === $sku) {
            throw new \InvalidArgumentException('Missing the required parameter $sku when calling patchListingsItem');
        }
        if (null === $body) {
            throw new \InvalidArgumentException('Missing the required parameter $body when calling patchListingsItem');
        }
        if (!array_key_exists('marketplaceIds', $params) ||  null === $params['marketplaceIds']) {
            throw new \InvalidArgumentException('Missing the required parameter $marketplaceIds when calling patchListingsItem');
        }

        $resource_path = '/listings/2021-08-01/items/{sellerId}/{sku}';
        $http_body = $body;
        $query_params = [];
        $method = 'PATCH';

        // path params
        if (null !== $sku) {
            $resource_path = str_replace(
                '{' . 'sku' . '}',
                rawurlencode($sku),
                $resource_path
            );
        }
        if (null !== $seller_id) {
            $resource_path = str_replace(
                '{' . 'sellerId' . '}',
                rawurlencode($seller_id),
                $resource_path
            );
        }
        
        // query params
        if (array_key_exists('marketplaceIds', $params) && $params['marketplaceIds'] !== null) {
            $query_params['marketplaceIds'] =   $params['marketplaceIds'];
        }
        if (array_key_exists('issueLocale', $params) && $params['issueLocale'] !== null) {
            $query_params['issueLocale'] =   $params['issueLocale'];
        }

        $curl_headers = $this->generateRequest($resource_path, $query_params, $http_body, $this->config, $method);
        $url = $this->config->getHost() . $resource_path;

        return $this->sendRequest($url, $query_params, $http_body, $curl_headers, $method);
    }
}
