<?php

namespace Tops\AmazonSellingPartnerAPI\Api;

class FbaSmallAndLightApi extends BaseApi
{
    /**
     * Operation Get Small And Light Enrollment By Seller SKU
     *
     * @param string $seller_sku The seller SKU that identifies the item. (required)
     * @param string|array $params['marketplaceIds'] The marketplace for which the enrollment status is retrieved. Note: Accepts a single marketplace only. <Max count : 1> (required)
     *
     * @return json Returns the Small and Light enrollment status for the item indicated by the specified seller SKU in the specified marketplace.
     *
     * @author Chetan Meena <chetan@topsinfosolutions.com>
     *
     * about more Ref: https://github.com/amzn/selling-partner-api-docs/blob/main/references/fba-small-and-light-api/fbaSmallandLight.md#getsmallandlightenrollmentbysellersku
     */
    public function getSmallAndLightEnrollmentBySellerSKU($params, $seller_sku)
    {
        if (!array_key_exists('marketplaceIds', $params) ||  null === $params['marketplaceIds']) {
            throw new \InvalidArgumentException('Missing the required parameter $marketplaceIds when calling getOrderItemsBuyerInfo');
        }

        if (null === $seller_sku) {
            throw new \InvalidArgumentException('Missing the required parameter $seller_sku when calling getOrderItemsBuyerInfo');
        }

        $resource_path = '/fba/smallAndLight/v1/enrollments/{sellerSKU}';
        $http_body = '';
        $query_params = [];
        $method = 'GET';

        // query params
        if (array_key_exists('marketplaceIds', $params) && $params['marketplaceIds'] !== null) {
            $query_params['marketplaceIds'] = is_array($params['marketplaceIds']) ? implode(',', $params['marketplaceIds']) :  $params['marketplace_ids'];
        }
      
        // path params
        if (null !== $seller_sku) {
            $resource_path = str_replace(
                '{' . 'sellerSKU' . '}',
                rawurlencode($seller_sku),
                $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 Put Small And Light Enrollment By Seller SKU
     *
     * @param string $seller_sku 	The seller SKU that identifies the item. (required)
     * @param string|array $params['marketplaceIds'] The marketplace for which the enrollment status is retrieved. Note: Accepts a single marketplace only. <Max count : 1> (required)
     *
     * @return json\
     *
     * @author Chetan Meena <chetan@topsinfosolutions.com>
     *
     * about more Ref:  https://github.com/amzn/selling-partner-api-docs/blob/main/references/fba-small-and-light-api/fbaSmallandLight.md#putsmallandlightenrollmentbysellersku
     */

    public function putSmallAndLightEnrollmentBySellerSKU($params, $seller_sku)
    {
        if (!array_key_exists('marketplaceIds', $params) ||  null === $params['marketplaceIds']) {
            throw new \InvalidArgumentException('Missing the required parameter $marketplaceIds when calling getOrderItemsBuyerInfo');
        }

        if (null === $seller_sku) {
            throw new \InvalidArgumentException('Missing the required parameter $seller_sku when calling getOrderItemsBuyerInfo');
        }

        $resource_path = '/fba/smallAndLight/v1/enrollments/{sellerSKU}';
        $http_body = '';
        $query_params = [];
        $method = 'PUT';

        // query params
        if (array_key_exists('marketplaceIds', $params) && $params['marketplaceIds'] !== null) {
            $query_params['marketplaceIds'] = is_array($params['marketplaceIds']) ? implode(',', $params['marketplaceIds']) :  $params['marketplace_ids'];
        }
      
        // path params
        if (null !== $seller_sku) {
            $resource_path = str_replace(
                '{' . 'sellerSKU' . '}',
                rawurlencode($seller_sku),
                $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 Delete Small And Light Enrollment By Seller SKU
     *
     * @param string $params['sellerSKU']  	The seller SKU that identifies the item. (required)
     * @param string|array $params['marketplaceIds'] The marketplace for which the enrollment status is retrieved. Note: Accepts a single marketplace only. <Max count : 1> (required)
     *
     * @return json\
     *
     * @author Chetan Meena <chetan@topsinfosolutions.com>
     *
     * about more Ref: https://github.com/amzn/selling-partner-api-docs/blob/main/references/fba-small-and-light-api/fbaSmallandLight.md#deletesmallandlightenrollmentbysellersku
     */
    public function deleteSmallAndLightEnrollmentBySellerSKU($params, $seller_sku)
    {
        if (!array_key_exists('marketplaceIds', $params) ||  null === $params['marketplaceIds']) {
            throw new \InvalidArgumentException('Missing the required parameter $marketplaceIds when calling getOrderItemsBuyerInfo');
        }

        if (null === $seller_sku) {
            throw new \InvalidArgumentException('Missing the required parameter $seller_sku when calling getOrderItemsBuyerInfo');
        }

        $resource_path = '/fba/smallAndLight/v1/enrollments/{sellerSKU}';
        $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['marketplace_ids'];
        }
      
        // path params
        if (null !== $seller_sku) {
            $resource_path = str_replace(
                '{' . 'sellerSKU' . '}',
                rawurlencode($seller_sku),
                $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 Get Small And Light Eligibility By Seller SKU
     *
     * @param string  $seller_sku	The seller SKU that identifies the item. (required)
     * @param string|array $params['marketplaceIds'] The marketplace for which the enrollment status is retrieved. Note: Accepts a single marketplace only. <Max count : 1> (required)
     *
     * @return json\
     *
     * @author Chetan Meena <chetan@topsinfosolutions.com>
     *
     * about more Ref: https://github.com/amzn/selling-partner-api-docs/blob/main/references/fba-small-and-light-api/fbaSmallandLight.md#getsmallandlighteligibilitybysellersku
     */
    public function getSmallAndLightEligibilityBySellerSKU($params, $seller_sku)
    {
        if (!array_key_exists('marketplaceIds', $params) ||  null === $params['marketplaceIds']) {
            throw new \InvalidArgumentException('Missing the required parameter $marketplaceIds when calling getOrderItemsBuyerInfo');
        }

        if (null === $seller_sku) {
            throw new \InvalidArgumentException('Missing the required parameter $seller_sku when calling getOrderItemsBuyerInfo');
        }
     
        $resource_path = '/fba/smallAndLight/v1/eligibilities/{sellerSKU}';
        $http_body = '';
        $query_params = [];
        $method = 'GET';

        // query params
        if (array_key_exists('marketplaceIds', $params) && $params['marketplaceIds'] !== null) {
            $query_params['marketplaceIds'] = is_array($params['marketplaceIds']) ? implode(',', $params['marketplaceIds']) :  $params['marketplace_ids'];
        }
      
        // path params
        if (null !== $seller_sku) {
            $resource_path = str_replace(
                '{' . 'sellerSKU' . '}',
                rawurlencode($seller_sku),
                $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 Get Small And Light Fee Preview
     *
     * @param array $body Request schema for submitting items for which to retrieve fee estimates.
     * @param string $body['marketplaceId'] A marketplace identifier. (required)
     * @param array $body['items'] A list of items for which to retrieve fee estimates (limit: 25). (required)
     * @return json\
     *
     * @author Chetan Meena <chetan@topsinfosolutions.com>
     *
     * about more Ref: https://github.com/amzn/selling-partner-api-docs/blob/main/references/fba-small-and-light-api/fbaSmallandLight.md#getsmallandlightfeepreview
     */
    public function getSmallAndLightFeePreview($body)
    {
        $resource_path = '/fba/smallAndLight/v1/feePreviews';
        $url = $this->config->getHost() . $resource_path;
        $http_body =  http_build_query($body);
        $query_params = [];
        $method = 'POST';

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

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