<?php

namespace Tops\AmazonSellingPartnerAPI\Api;

class FbaShipment extends BaseApi
{

    /**
     * Operation Create Inbound Shipment Plan
     *
     * @param array $body The request schema for the createInboundShipmentPlan operation.
     * @param array $body['ShipFromAddress'] The address from which the inbound shipment will be sent. (required)
     * @param enum $body['LabelPrepPreference'] The seller's preference for label preparation for an inbound shipment. (required)
     * @param string $body['ShipToCountryCode'] The two-character country code for the country where the inbound shipment is to be sent. Note: Not required. Specifying both ShipToCountryCode and ShipToCountrySubdivisionCode returns an error. Default: The country code for the seller's home marketplace.
     * @param string $body['ShipToCountrySubdivisionCode'] The two-character country code, followed by a dash and then up to three characters that represent the subdivision of the country where the inbound shipment is to be sent. For example, "IN-MH". In full ISO 3166-2 format.
     * @param array $body['InboundShipmentPlanRequestItems'] Item information for creating an inbound shipment plan. (required)
     * @return json\
     *
     * @author Haresh Pithiya <hareshpithiya@topsinfosolutions.com>
     *
     * about more Ref: https://github.com/amzn/selling-partner-api-docs/blob/main/references/fulfillment-inbound-api/fulfillmentInboundV0.md#createinboundshipmentplan
     */
    public function createInboundShipmentPlan($body)
    {
        $resource_path = '/fba/inbound/v0/plans';
        $url = $this->config->getHost() . $resource_path;
        $query_params = [];
        $method = 'POST';

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

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


    /**
     * Operation Create Inbound Shipment
     *
     * @param array $body The request schema for an inbound shipment.
     * @param string $params['shipmentId'] A shipment identifier originally returned by the createInboundShipmentPlan operation. (required)
     * @param array $body['InboundShipmentHeader'] Inbound shipment information used to create and update inbound shipments. (required)
     * @param array $body['InboundShipmentItems'] A list of inbound shipment item information. (required)
     * @param string $body['MarketplaceId'] A marketplace identifier. Specifies the marketplace where the product would be stored. (required)
     * @return json\
     *
     * @author Haresh Pithiya <hareshpithiya@topsinfosolutions.com>
     *
     * about more Ref: https://github.com/amzn/selling-partner-api-docs/blob/main/references/fulfillment-inbound-api/fulfillmentInboundV0.md#createinboundshipment
     */
    public function createInboundShipment($body, $shipmentId)
    {
        $shipmentId = rawurlencode($shipmentId);
        $resource_path = '/fba/inbound/v0/shipments/'.$shipmentId;
        $url = $this->config->getHost() . $resource_path;
        $query_params = [];
        $method = 'POST';

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

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


    /**
     * Operation Update Inbound Shipment
     *
     * @param array $body The request schema for an inbound shipment.
     * @param string $params['shipmentId'] A shipment identifier originally returned by the createInboundShipmentPlan operation. (required)
     * @param array $body['InboundShipmentHeader'] Inbound shipment information used to create and update inbound shipments. (required)
     * @param array $body['InboundShipmentItems'] A list of inbound shipment item information. (required)
     * @param string $body['MarketplaceId'] A marketplace identifier. Specifies the marketplace where the product would be stored. (required)
     * @return json\
     *
     * @author Haresh Pithiya <hareshpithiya@topsinfosolutions.com>
     *
     * about more Ref: https://github.com/amzn/selling-partner-api-docs/blob/main/references/fulfillment-inbound-api/fulfillmentInboundV0.md#updateinboundshipment
     */
    public function updateInboundShipment($body, $shipmentId)
    {
        $shipmentId = rawurlencode($shipmentId);
        $resource_path = '/fba/inbound/v0/shipments/'.$shipmentId;
        $url = $this->config->getHost() . $resource_path;
        $query_params = [];
        $method = 'PUT';

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

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


    /**
     * Operation Put Transport Content
     *
     * @param array $body The request schema for a putTransportDetails operation.
     * @param string $params['shipmentId'] A shipment identifier originally returned by the createInboundShipmentPlan operation. (required)
     * @param boolean $body['IsPartnered'] Indicates whether a putTransportDetails request is for an Amazon-partnered carrier. (required)
     * @param enum $body['ShipmentType'] Specifies the carrier shipment type in a putTransportDetails request. (required)
     * @param array $body['TransportDetails'] Information required to create an Amazon-partnered carrier shipping estimate, or to alert the Amazon fulfillment center to the arrival of an inbound shipment by a non-Amazon-partnered carrier. (required)
     * @return json\
     *
     * @author Haresh Pithiya <hareshpithiya@topsinfosolutions.com>
     *
     * about more Ref: https://github.com/amzn/selling-partner-api-docs/blob/main/references/fulfillment-inbound-api/fulfillmentInboundV0.md#puttransportdetails
     */
    public function putTransportDetails($body, $shipmentId)
    {
        $shipmentId = rawurlencode($shipmentId);
        $resource_path = '/fba/inbound/v0/shipments/'.$shipmentId.'/transport';
        $url = $this->config->getHost() . $resource_path;
        $query_params = [];
        $method = 'PUT';

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

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


    /**
     * Operation Estimate Transport Request
     *
     * @param string $params['shipmentId'] A shipment identifier originally returned by the createInboundShipmentPlan operation. (required)
     * @return json\
     *
     * @author Haresh Pithiya <hareshpithiya@topsinfosolutions.com>
     *
     * about more Ref: https://github.com/amzn/selling-partner-api-docs/blob/main/references/fulfillment-inbound-api/fulfillmentInboundV0.md#estimatetransport
     */
    public function estimateTransport($shipmentId)
    {
        $shipmentId = rawurlencode($shipmentId);
        $resource_path = '/fba/inbound/v0/shipments/'.$shipmentId.'/transport/estimate';
        $url = $this->config->getHost() . $resource_path;
        $http_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);
    }

    /**
     * Operation Confirm Transport Request
     *
     * @param string $params['shipmentId'] A shipment identifier originally returned by the createInboundShipmentPlan operation. (required)
     * @return json\
     *
     * @author Haresh Pithiya <hareshpithiya@topsinfosolutions.com>
     *
     * about more Ref: https://github.com/amzn/selling-partner-api-docs/blob/main/references/fulfillment-inbound-api/fulfillmentInboundV0.md#confirmtransport
     */
    public function confirmTransport($shipmentId)
    {
        $shipmentId = rawurlencode($shipmentId);
        $resource_path = '/fba/inbound/v0/shipments/'.$shipmentId.'/transport/confirm';
        $url = $this->config->getHost() . $resource_path;
        $http_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);
    }

    /**
     * Operation Void Transport Request
     *
     * @param string $params['shipmentId'] A shipment identifier originally returned by the createInboundShipmentPlan operation. (required)
     * @return json\
     *
     * @author Haresh Pithiya <hareshpithiya@topsinfosolutions.com>
     *
     * about more Ref: https://github.com/amzn/selling-partner-api-docs/blob/main/references/fulfillment-inbound-api/fulfillmentInboundV0.md#voidtransport
     */
    public function voidTransport($shipmentId)
    {
        $shipmentId = rawurlencode($shipmentId);
        $resource_path = '/fba/inbound/v0/shipments/'.$shipmentId.'/transport/void';
        $url = $this->config->getHost() . $resource_path;
        $http_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);
    }

    /**
     * Operation Get Transport Content
     *
     * @param string $params['shipmentId'] A shipment identifier originally returned by the createInboundShipmentPlan operation. (required)
     * @return json\
     *
     * @author Haresh Pithiya <hareshpithiya@topsinfosolutions.com>
     *
     * about more Ref: https://github.com/amzn/selling-partner-api-docs/blob/main/references/fulfillment-inbound-api/fulfillmentInboundV0.md#gettransportdetails
     */
    public function getTransportDetails($shipmentId)
    {
        $shipmentId = rawurlencode($shipmentId);
        $resource_path = '/fba/inbound/v0/shipments/'.$shipmentId.'/transport';
        $url = $this->config->getHost() . $resource_path;
        $http_body = '';
        $query_params = [];
        $method = 'GET';

        $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 Unique Package Labels
     *
     * @param string $params['shipmentId'] A shipment identifier originally returned by the createInboundShipmentPlan operation. (required)
     * @param enum $params['PageType'] The page type to use to print the labels. Submitting a PageType value that is not supported in your marketplace returns an error. (required)
     * @param enum $params['LabelType'] The type of labels requested. (required)
     * @param integer $params['NumberOfPackages'] The number of packages in the shipment.
     * @param string|array $params['PackageLabelsToPrint'] A list of identifiers that specify packages for which you want package labels printed.
     * @param integer $params['NumberOfPallets'] The number of pallets in the shipment. This returns four identical labels for each pallet.
     * @param integer $params['PageSize'] The page size for paginating through the total packages' labels. This is a required parameter for Non-Partnered LTL Shipments. Max value:1000.
     * @param integer $params['PageStartIndex'] The page start index for paginating through the total packages' labels. This is a required parameter for Non-Partnered LTL Shipments.
     * @return json\
     *
     * @author Haresh Pithiya <hareshpithiya@topsinfosolutions.com>
     *
     * about more Ref: https://github.com/amzn/selling-partner-api-docs/blob/main/references/fulfillment-inbound-api/fulfillmentInboundV0.md#getlabels
     */
    public function getLabels($params, $shipmentId)
    {
        $shipmentId = rawurlencode($shipmentId);
        $resource_path = '/fba/inbound/v0/shipments/'.$shipmentId.'/labels';
        $url = $this->config->getHost() . $resource_path;
        $http_body = '';
        $query_params = $params;
        $method = 'GET';

        $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 Bill Of Shipment
     *
     * @param string $params['shipmentId'] A shipment identifier originally returned by the createInboundShipmentPlan operation. (required)
     * 
     * @return json\
     *
     * @author Haresh Pithiya <hareshpithiya@topsinfosolutions.com>
     *
     * about more Ref: https://github.com/amzn/selling-partner-api-docs/blob/main/references/fulfillment-inbound-api/fulfillmentInboundV0.md#getbilloflading
     */
    public function getBillOfLading($shipmentId)
    {
        $shipmentId = rawurlencode($shipmentId);
        $resource_path = '/fba/inbound/v0/shipments/'.$shipmentId.'/billOfLading';
        $url = $this->config->getHost() . $resource_path;
        $http_body = '';
        $query_params = [];
        $method = 'GET';

        $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 List Of Inbound Shipments
     *
     * @param enum|array $params['ShipmentStatusList'] A list of ShipmentStatus values. Used to select shipments with a current status that matches the status values that you specify.
     * @param string|array $params['ShipmentIdList'] A list of shipment IDs used to select the shipments that you want. If both ShipmentStatusList and ShipmentIdList are specified, only shipments that match both parameters are returned.
     * @param string (date-time) $params['LastUpdatedAfter']  A date used for selecting inbound shipments that were last updated after (or at) a specified time. The selection includes updates made by Amazon and by the seller.
     * @param string (date-time) $params['LastUpdatedBefore'] A date used for selecting inbound shipments that were last updated before (or at) a specified time. The selection includes updates made by Amazon and by the seller.
     * @param enum $params['QueryType'] Indicates whether shipments are returned using shipment information (by providing the ShipmentStatusList or ShipmentIdList parameters), using a date range (by providing the LastUpdatedAfter and LastUpdatedBefore parameters), or by using NextToken to continue returning items specified in a previous request. (required)
     * @param string $params['NextToken'] String token returned in the response of your previous request.
     * @param string $params['MarketplaceId'] The marketplace ID for the marketplace for which to return inventory summaries. (required)
     *
     * @return json\
     *
     * @author Haresh Pithiya <hareshpithiya@topsinfosolutions.com>
     *
     * about more Ref: https://github.com/amzn/selling-partner-api-docs/blob/main/references/fulfillment-inbound-api/fulfillmentInboundV0.md#getshipments
     */
    public function getShipments($params)
    {
        $resource_path = '/fba/inbound/v0/shipments';
        $url = $this->config->getHost() . $resource_path;
        $http_body = '';
        $query_params = $params;
        $method = 'GET';

        $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 Inbound Guidance
     *
     * @param string $params['MarketplaceId'] The marketplace ID for the marketplace for which to return inventory summaries. (required)
     * @param string|array $params['SellerSKUList'] A list of SellerSKU values. Used to identify items for which you want inbound guidance for shipment to Amazon's fulfillment network. Max count : 50
     * @param string|array $params['ASINList'] A list of ASIN values. Used to identify items for which you want inbound guidance for shipment to Amazon's fulfillment network. Max count : 50
     *
     * @return json\
     *
     * @author Haresh Pithiya <hareshpithiya@topsinfosolutions.com>
     *
     * about more Ref: https://github.com/amzn/selling-partner-api-docs/blob/main/references/fulfillment-inbound-api/fulfillmentInboundV0.md#getinboundguidance
     */
    public function getInboundGuidance($params)
    {
        $resource_path = '/fba/inbound/v0/itemsGuidance';
        $url = $this->config->getHost() . $resource_path;
        $http_body = '';
        $query_params = $params;
        $method = 'GET';

        $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 Preorder Info
     *
     * @param string $params['shipmentId'] A shipment identifier originally returned by the createInboundShipmentPlan operation. (required)
     * @param string $params['MarketplaceId'] The marketplace ID for the marketplace for which to return inventory summaries. (required)
     *
     * @return json\
     *
     * @author Haresh Pithiya <hareshpithiya@topsinfosolutions.com>
     *
     * about more Ref: https://github.com/amzn/selling-partner-api-docs/blob/main/references/fulfillment-inbound-api/fulfillmentInboundV0.md#getpreorderinfo
     */
    public function getPreorderInfo($params, $shipmentId)
    {
        $shipmentId = rawurlencode($shipmentId);
        $resource_path = '/fba/inbound/v0/shipments/'.$shipmentId.'/preorder';
        $url = $this->config->getHost() . $resource_path;
        $http_body = '';
        $query_params = $params;
        $method = 'GET';

        $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 Confirm Preorder Info
     *
     * @param string $params['shipmentId'] A shipment identifier originally returned by the createInboundShipmentPlan operation. (required)
     * @param string $params['NeedByDate'] Date that the shipment must arrive at the Amazon fulfillment center to avoid delivery promise breaks for pre-ordered items. Must be in YYYY-MM-DD format. The response to the getPreorderInfo operation returns this value. (required)
     * @param string $params['MarketplaceId'] The marketplace ID for the marketplace for which to return inventory summaries. (required)
     *
     * @return json\
     *
     * @author Haresh Pithiya <hareshpithiya@topsinfosolutions.com>
     *
     * about more Ref: https://github.com/amzn/selling-partner-api-docs/blob/main/references/fulfillment-inbound-api/fulfillmentInboundV0.md#confirmpreorder
     */
    public function confirmPreorder($params, $shipmentId)
    {
        $shipmentId = rawurlencode($shipmentId);
        $resource_path = '/fba/inbound/v0/shipments/'.$shipmentId.'/preorder/confirm';
        $url = $this->config->getHost() . $resource_path;
        $http_body = '';
        $query_params = $params;
        $method = 'PUT';

        $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 Labeling Requirements and Item Preparation Instructions
     *
     * @param string $params['ShipToCountryCode'] The country code of the country to which the items will be shipped. Note that labeling requirements and item preparation instructions can vary by country. (required)
     * @param string|array $params['SellerSKUList'] A list of SellerSKU values. Used to identify items for which you want labeling requirements and item preparation instructions for shipment to Amazon's fulfillment network. The SellerSKU is qualified by the Seller ID, which is included with every call to the Seller Partner API.
     * @param string|array $params['ASINList'] A list of ASIN values. Used to identify items for which you want item preparation instructions to help with item sourcing decisions.
     *
     * @return json\
     *
     * @author Haresh Pithiya <hareshpithiya@topsinfosolutions.com>
     *
     * about more Ref: https://github.com/amzn/selling-partner-api-docs/blob/main/references/fulfillment-inbound-api/fulfillmentInboundV0.md#getprepinstructions
     */
    public function getPrepInstructions($params)
    {
        $resource_path = '/fba/inbound/v0/prepInstructions';
        $url = $this->config->getHost() . $resource_path;
        $http_body = '';
        $query_params = $params;
        $method = 'GET';

        $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 Shipment Items By ShipmentId
     *
     * @param string $params['shipmentId'] A shipment identifier originally returned by the createInboundShipmentPlan operation. (required)
     * @param string $params['MarketplaceId'] The marketplace ID for the marketplace for which to return inventory summaries. (required)
     *
     * @return json\
     *
     * @author Haresh Pithiya <hareshpithiya@topsinfosolutions.com>
     *
     * about more Ref: https://github.com/amzn/selling-partner-api-docs/blob/main/references/fulfillment-inbound-api/fulfillmentInboundV0.md#getshipmentitemsbyshipmentid
     */
    public function getShipmentItemsByShipmentId($params, $shipmentId)
    {
        $shipmentId = rawurlencode($shipmentId);
        $resource_path = '/fba/inbound/v0/shipments/'.$shipmentId.'/items';
        $url = $this->config->getHost() . $resource_path;
        $http_body = '';
        $query_params = $params;
        $method = 'GET';

        $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 Shipment Items
     *
     * @param string $params['LastUpdatedAfter'] A date used for selecting inbound shipment items that were last updated after (or at) a specified time. The selection includes updates made by Amazon and by the seller.
     * @param string $params['LastUpdatedBefore'] A date used for selecting inbound shipment items that were last updated before (or at) a specified time. The selection includes updates made by Amazon and by the seller.
     * @param enum $params['QueryType'] Indicates whether items are returned using a date range (by providing the LastUpdatedAfter and LastUpdatedBefore parameters), or using NextToken, which continues returning items specified in a previous request. (required)
     * @param string $params['NextToken'] A string token returned in the response to your previous request.
     * @param string $params['MarketplaceId'] The marketplace ID for the marketplace for which to return inventory summaries. (required)
     * @return json\
     *
     * @author Haresh Pithiya <hareshpithiya@topsinfosolutions.com>
     *
     * about more Ref: https://github.com/amzn/selling-partner-api-docs/blob/main/references/fulfillment-inbound-api/fulfillmentInboundV0.md#getshipmentitems
     */
    public function getShipmentItems($params)
    {
        $resource_path = '/fba/inbound/v0/shipmentItems';
        $url = $this->config->getHost() . $resource_path;
        $http_body = '';
        $query_params = $params;
        $method = 'GET';

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

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