<?php

namespace Tops\AmazonSellingPartnerAPI\Api;

class APlusContentApi 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 searchContentDocuments($params)
    {
        if (!array_key_exists('marketplaceId', $params) ||  null === $params['marketplaceId']) {
            throw new \InvalidArgumentException('Missing the required parameter $marketplaceId when calling searchContentDocuments');
        }

        $resource_path = '/aplus/2020-11-01/contentDocuments';
        $url = $this->config->getHost() . $resource_path;
        $http_body = '';
        $query_params = [];
        $method = 'GET';

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

        $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 createContentDocument($params, $body)
    {
        if (!array_key_exists('marketplaceId', $params) ||  null === $params['marketplaceId']) {
            throw new \InvalidArgumentException('Missing the required parameter $marketplaceId when calling createContentDocument');
        }
        if (!array_key_exists('postContentDocumentRequest', $body) ||  null === $body['postContentDocumentRequest']) {
            throw new \InvalidArgumentException('Missing the required parameter $postContentDocumentRequest when calling createContentDocument');
        }

        $resource_path = '/aplus/2020-11-01/contentDocuments';
        $http_body = $body;
        $query_params = [];
        $method = 'POST';

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

        $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 getContentDocument($params, $content_reference_key)
    {
        if (!array_key_exists('marketplaceId', $params) ||  null === $params['marketplaceId']) {
            throw new \InvalidArgumentException('Missing the required parameter $marketplaceId when calling getContentDocument');
        }
        if (!array_key_exists('includedDataSet', $params) ||  null === $params['includedDataSet']) {
            throw new \InvalidArgumentException('Missing the required parameter $includedDataSet when calling getContentDocument');
        }
        if (null === $content_reference_key) {
            throw new \InvalidArgumentException('Missing the required parameter $content_reference_key when calling getContentDocument');
        }

        $resource_path = '/aplus/2020-11-01/contentDocuments/{contentReferenceKey}';
        $http_body = '';
        $query_params = [];
        $method = 'GET';

        // path params
        if (null !== $content_reference_key) {
            $resource_path = str_replace(
                '{' . 'contentReferenceKey' . '}',
                rawurlencode($content_reference_key),
                $resource_path
            );
        }

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

        $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 updateContentDocument($params, $content_reference_key, $body)
    {
        if (!array_key_exists('marketplaceId', $params) ||  null === $params['marketplaceId']) {
            throw new \InvalidArgumentException('Missing the required parameter $marketplaceId when calling updateContentDocument');
        }
        if (null === $content_reference_key) {
            throw new \InvalidArgumentException('Missing the required parameter $content_reference_key when calling updateContentDocument');
        }

        $resource_path = '/aplus/2020-11-01/contentDocuments/{contentReferenceKey}';
        $http_body = $body;
        $query_params = [];
        $method = 'POST';

        // path params
        if (null !== $content_reference_key) {
            $resource_path = str_replace(
                '{' . 'contentReferenceKey' . '}',
                rawurlencode($content_reference_key),
                $resource_path
            );
        }

        // query params
        if (array_key_exists('marketplaceId', $params) && $params['marketplaceId'] !== null) {
            $query_params['marketplaceId'] =   $params['marketplaceId'];
        }
        
        $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 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 listContentDocumentAsinRelations($params, $content_reference_key)
    {
        if (!array_key_exists('marketplaceId', $params) ||  null === $params['marketplaceId']) {
            throw new \InvalidArgumentException('Missing the required parameter $marketplaceId when calling listContentDocumentAsinRelations');
        }
        if (null === $content_reference_key) {
            throw new \InvalidArgumentException('Missing the required parameter $content_reference_key when calling getOrderItemsBuyerInfo');
        }

        $resource_path = '/aplus/2020-11-01/contentDocuments/{contentReferenceKey}/asins';
        $url = $this->config->getHost() . $resource_path;
        $http_body = '';
        $query_params = [];
        $method = 'GET';

        // query params
        if (array_key_exists('marketplaceId', $params) && $params['marketplaceId'] !== null) {
            $query_params['marketplaceId'] = $params['marketplaceId'];
        }
        if (array_key_exists('includedDataSet', $params) && $params['includedDataSet'] !== null) {
            $query_params['includedDataSet'] = $params['includedDataSet'];
        }
        if (array_key_exists('asinSet', $params) && $params['asinSet'] !== null) {
            $query_params['asinSet'] = $params['asinSet'];
        }
        if (array_key_exists('pageToken', $params) && $params['pageToken'] !== null) {
            $query_params['pageToken'] = $params['pageToken'];
        }

        // path params
        if (null !== $content_reference_key) {
            $resource_path = str_replace(
                '{' . 'contentReferenceKey' . '}',
                $content_reference_key,
                $resource_path
            );
        }

        $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 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 postContentDocumentAsinRelations($params, $content_reference_key, $body)
    {
        if (!array_key_exists('marketplaceId', $params) ||  null === $params['marketplaceId']) {
            throw new \InvalidArgumentException('Missing the required parameter $marketplaceId when calling postContentDocumentAsinRelations');
        }
        if (null === $content_reference_key) {
            throw new \InvalidArgumentException('Missing the required parameter $content_reference_key when calling postContentDocumentAsinRelations');
        }

        $resource_path = '/aplus/2020-11-01/contentDocuments/{contentReferenceKey}/asins';
        $http_body = $body;
        $query_params = [];
        $method = 'POST';

        // path params
        if (null !== $content_reference_key) {
            $resource_path = str_replace(
                '{' . 'contentReferenceKey' . '}',
                rawurlencode($content_reference_key),
                $resource_path
            );
        }

        // query params
        if (array_key_exists('marketplaceId', $params) && $params['marketplaceId'] !== null) {
            $query_params['marketplaceId'] =   $params['marketplaceId'];
        }
        
        $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 validateContentDocumentAsinRelations($params, $body)
    {
        if (!array_key_exists('marketplaceId', $params) ||  null === $params['marketplaceId']) {
            throw new \InvalidArgumentException('Missing the required parameter $marketplaceId when calling validateContentDocumentAsinRelations');
        }

        $resource_path = '/aplus/2020-11-01/contentAsinValidations';
        $http_body = $body;
        $query_params = [];
        $method = 'POST';

        // query params
        if (array_key_exists('marketplaceId', $params) && $params['marketplaceId'] !== null) {
            $query_params['marketplaceId'] =   $params['marketplaceId'];
        }
        if (array_key_exists('asinSet', $params) && $params['asinSet'] !== null) {
            $query_params['asinSet'] =   $params['asinSet'];
        }
        
        $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 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 searchContentPublishRecords($params)
    {
        if (!array_key_exists('marketplaceId', $params) ||  null === $params['marketplaceId']) {
            throw new \InvalidArgumentException('Missing the required parameter $marketplaceId when calling searchContentPublishRecords');
        }
        if (!array_key_exists('asin', $params) ||  null === $params['asin']) {
            throw new \InvalidArgumentException('Missing the required parameter $asin when calling searchContentPublishRecords');
        }

        $resource_path = '/aplus/2020-11-01/contentPublishRecords';
        $url = $this->config->getHost() . $resource_path;
        $http_body = '';
        $query_params = [];
        $method = 'GET';

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

        $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 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 postContentDocumentApprovalSubmission($params, $content_reference_key)
    {
        if (!array_key_exists('marketplaceId', $params) ||  null === $params['marketplaceId']) {
            throw new \InvalidArgumentException('Missing the required parameter $marketplaceId when calling postContentDocumentApprovalSubmission');
        }
        if (null === $content_reference_key) {
            throw new \InvalidArgumentException('Missing the required parameter $content_reference_key when calling postContentDocumentApprovalSubmission');
        }

        $resource_path = '/aplus/2020-11-01/contentDocuments/{contentReferenceKey}/approvalSubmissions';
        $http_body = '';
        $query_params = [];
        $method = 'POST';

        // path params
        if (null !== $content_reference_key) {
            $resource_path = str_replace(
                '{' . 'contentReferenceKey' . '}',
                $content_reference_key,
                $resource_path
            );
        }

        // query params
        if (array_key_exists('marketplaceId', $params) && $params['marketplaceId'] !== null) {
            $query_params['marketplaceId'] =   $params['marketplaceId'];
        }
        
        $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 postContentDocumentSuspendSubmission($params, $content_reference_key)
    {
        if (!array_key_exists('marketplaceId', $params) ||  null === $params['marketplaceId']) {
            throw new \InvalidArgumentException('Missing the required parameter $marketplaceId when calling postContentDocumentSuspendSubmission');
        }
        if (null === $content_reference_key) {
            throw new \InvalidArgumentException('Missing the required parameter $content_reference_key when calling postContentDocumentSuspendSubmission');
        }

        $resource_path = '/aplus/2020-11-01/contentDocuments/{contentReferenceKey}/suspendSubmissions';
        $http_body = '';
        $query_params = [];
        $method = 'POST';

        // path params
        if (null !== $content_reference_key) {
            $resource_path = str_replace(
                '{' . 'contentReferenceKey' . '}',
                $content_reference_key,
                $resource_path
            );
        }

        // query params
        if (array_key_exists('marketplaceId', $params) && $params['marketplaceId'] !== null) {
            $query_params['marketplaceId'] =   $params['marketplaceId'];
        }
        
        $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);
    }
}
