# coding: utf-8

"""
    Selling Partner API for FBA Inventory

    The Selling Partner API for FBA Inventory lets you programmatically retrieve information about inventory in Amazon's fulfillment network.

    The version of the OpenAPI document: v1
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501


from __future__ import absolute_import

import re  # noqa: F401

# python 2 and python 3 compatibility library
import six

from spapi.api_client import ApiClient


class FbaInventoryApi(object):
    """NOTE: This class is auto generated by the openapi generator.

    Do not edit the class manually.
    """

    api_models_module = "spapi.models.fba_inventory_v1"

    def __init__(self, api_client=None):
        if api_client is None:
            api_client = ApiClient()
        self.api_client = api_client
        self.classFileName = 'fba_inventory_api'

    def add_inventory(self, x_amzn_idempotency_token, add_inventory_request_body, **kwargs):  # noqa: E501
        """add_inventory  # noqa: E501

        Requests that Amazon add items to the Sandbox Inventory with desired amount of quantity in the sandbox environment. This is a sandbox-only operation and must be directed to a sandbox endpoint. Refer to [Selling Partner API sandbox](https://developer-docs.amazon.com/sp-api/docs/the-selling-partner-api-sandbox) for more information.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.add_inventory(x_amzn_idempotency_token, add_inventory_request_body, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str x_amzn_idempotency_token: A unique token/requestId provided with each call to ensure idempotency. (required)
        :param AddInventoryRequest add_inventory_request_body: List of items to add to Sandbox inventory. (required)
        :return: AddInventoryResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.add_inventory_with_http_info(x_amzn_idempotency_token, add_inventory_request_body, **kwargs)  # noqa: E501
        else:
            (data) = self.add_inventory_with_http_info(x_amzn_idempotency_token, add_inventory_request_body, **kwargs)  # noqa: E501
            return data

    def add_inventory_with_http_info(self, x_amzn_idempotency_token, add_inventory_request_body, **kwargs):  # noqa: E501
        """add_inventory  # noqa: E501

        Requests that Amazon add items to the Sandbox Inventory with desired amount of quantity in the sandbox environment. This is a sandbox-only operation and must be directed to a sandbox endpoint. Refer to [Selling Partner API sandbox](https://developer-docs.amazon.com/sp-api/docs/the-selling-partner-api-sandbox) for more information.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.add_inventory_with_http_info(x_amzn_idempotency_token, add_inventory_request_body, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str x_amzn_idempotency_token: A unique token/requestId provided with each call to ensure idempotency. (required)
        :param AddInventoryRequest add_inventory_request_body: List of items to add to Sandbox inventory. (required)
        :return: AddInventoryResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['x_amzn_idempotency_token', 'add_inventory_request_body']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in six.iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method add_inventory" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'x_amzn_idempotency_token' is set
        if self.api_client.client_side_validation and ('x_amzn_idempotency_token' not in params or
                                                       params['x_amzn_idempotency_token'] is None):  # noqa: E501
            raise ValueError("Missing the required parameter `x_amzn_idempotency_token` when calling `add_inventory`")  # noqa: E501
        # verify the required parameter 'add_inventory_request_body' is set
        if self.api_client.client_side_validation and ('add_inventory_request_body' not in params or
                                                       params['add_inventory_request_body'] is None):  # noqa: E501
            raise ValueError("Missing the required parameter `add_inventory_request_body` when calling `add_inventory`")  # noqa: E501

        collection_formats = {}

        path_params = {}

        query_params = []

        header_params = {}
        if 'x_amzn_idempotency_token' in params:
            header_params['x-amzn-idempotency-token'] = params['x_amzn_idempotency_token']  # noqa: E501

        form_params = []
        local_var_files = {}

        body_params = None
        if 'add_inventory_request_body' in params:
            body_params = params['add_inventory_request_body']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json'])  # noqa: E501

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.select_header_content_type(  # noqa: E501
            ['application/json'])  # noqa: E501

        # Authentication setting
        auth_settings = []  # noqa: E501

        return self.api_client.call_api(
            '/fba/inventory/v1/items/inventory', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='AddInventoryResponse',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats, api_models_module=self.api_models_module)

    def create_inventory_item(self, create_inventory_item_request_body, **kwargs):  # noqa: E501
        """create_inventory_item  # noqa: E501

        Requests that Amazon create product-details in the Sandbox Inventory in the sandbox environment. This is a sandbox-only operation and must be directed to a sandbox endpoint. Refer to [Selling Partner API sandbox](https://developer-docs.amazon.com/sp-api/docs/the-selling-partner-api-sandbox) for more information.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.create_inventory_item(create_inventory_item_request_body, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param CreateInventoryItemRequest create_inventory_item_request_body: CreateInventoryItem Request Body Parameter. (required)
        :return: CreateInventoryItemResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.create_inventory_item_with_http_info(create_inventory_item_request_body, **kwargs)  # noqa: E501
        else:
            (data) = self.create_inventory_item_with_http_info(create_inventory_item_request_body, **kwargs)  # noqa: E501
            return data

    def create_inventory_item_with_http_info(self, create_inventory_item_request_body, **kwargs):  # noqa: E501
        """create_inventory_item  # noqa: E501

        Requests that Amazon create product-details in the Sandbox Inventory in the sandbox environment. This is a sandbox-only operation and must be directed to a sandbox endpoint. Refer to [Selling Partner API sandbox](https://developer-docs.amazon.com/sp-api/docs/the-selling-partner-api-sandbox) for more information.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.create_inventory_item_with_http_info(create_inventory_item_request_body, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param CreateInventoryItemRequest create_inventory_item_request_body: CreateInventoryItem Request Body Parameter. (required)
        :return: CreateInventoryItemResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['create_inventory_item_request_body']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in six.iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method create_inventory_item" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'create_inventory_item_request_body' is set
        if self.api_client.client_side_validation and ('create_inventory_item_request_body' not in params or
                                                       params['create_inventory_item_request_body'] is None):  # noqa: E501
            raise ValueError("Missing the required parameter `create_inventory_item_request_body` when calling `create_inventory_item`")  # noqa: E501

        collection_formats = {}

        path_params = {}

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'create_inventory_item_request_body' in params:
            body_params = params['create_inventory_item_request_body']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json'])  # noqa: E501

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.select_header_content_type(  # noqa: E501
            ['application/json'])  # noqa: E501

        # Authentication setting
        auth_settings = []  # noqa: E501

        return self.api_client.call_api(
            '/fba/inventory/v1/items', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='CreateInventoryItemResponse',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats, api_models_module=self.api_models_module)

    def delete_inventory_item(self, seller_sku, marketplace_id, **kwargs):  # noqa: E501
        """delete_inventory_item  # noqa: E501

        Requests that Amazon Deletes an item from the Sandbox Inventory in the sandbox environment. This is a sandbox-only operation and must be directed to a sandbox endpoint. Refer to [Selling Partner API sandbox](https://developer-docs.amazon.com/sp-api/docs/the-selling-partner-api-sandbox) for more information.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.delete_inventory_item(seller_sku, marketplace_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str seller_sku: A single seller SKU used for querying the specified seller SKU inventory summaries. (required)
        :param str marketplace_id: The marketplace ID for the marketplace for which the sellerSku is to be deleted. (required)
        :return: DeleteInventoryItemResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.delete_inventory_item_with_http_info(seller_sku, marketplace_id, **kwargs)  # noqa: E501
        else:
            (data) = self.delete_inventory_item_with_http_info(seller_sku, marketplace_id, **kwargs)  # noqa: E501
            return data

    def delete_inventory_item_with_http_info(self, seller_sku, marketplace_id, **kwargs):  # noqa: E501
        """delete_inventory_item  # noqa: E501

        Requests that Amazon Deletes an item from the Sandbox Inventory in the sandbox environment. This is a sandbox-only operation and must be directed to a sandbox endpoint. Refer to [Selling Partner API sandbox](https://developer-docs.amazon.com/sp-api/docs/the-selling-partner-api-sandbox) for more information.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.delete_inventory_item_with_http_info(seller_sku, marketplace_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str seller_sku: A single seller SKU used for querying the specified seller SKU inventory summaries. (required)
        :param str marketplace_id: The marketplace ID for the marketplace for which the sellerSku is to be deleted. (required)
        :return: DeleteInventoryItemResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['seller_sku', 'marketplace_id']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in six.iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method delete_inventory_item" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'seller_sku' is set
        if self.api_client.client_side_validation and ('seller_sku' not in params or
                                                       params['seller_sku'] is None):  # noqa: E501
            raise ValueError("Missing the required parameter `seller_sku` when calling `delete_inventory_item`")  # noqa: E501
        # verify the required parameter 'marketplace_id' is set
        if self.api_client.client_side_validation and ('marketplace_id' not in params or
                                                       params['marketplace_id'] is None):  # noqa: E501
            raise ValueError("Missing the required parameter `marketplace_id` when calling `delete_inventory_item`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'seller_sku' in params:
            path_params['sellerSku'] = params['seller_sku']  # noqa: E501

        query_params = []
        if 'marketplace_id' in params:
            query_params.append(('marketplaceId', params['marketplace_id']))  # noqa: E501

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json'])  # noqa: E501

        # Authentication setting
        auth_settings = []  # noqa: E501

        return self.api_client.call_api(
            '/fba/inventory/v1/items/{sellerSku}', 'DELETE',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='DeleteInventoryItemResponse',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats, api_models_module=self.api_models_module)

    def get_inventory_summaries(self, granularity_type, granularity_id, marketplace_ids, **kwargs):  # noqa: E501
        """get_inventory_summaries  # noqa: E501

        Returns a list of inventory summaries. The summaries returned depend on the presence or absence of the startDateTime, sellerSkus and sellerSku parameters:  - All inventory summaries with available details are returned when the startDateTime, sellerSkus and sellerSku parameters are omitted. - When startDateTime is provided, the operation returns inventory summaries that have had changes after the date and time specified. The sellerSkus and sellerSku parameters are ignored. Important: To avoid errors, use both startDateTime and nextToken to get the next page of inventory summaries that have changed after the date and time specified. - When the sellerSkus parameter is provided, the operation returns inventory summaries for only the specified sellerSkus. The sellerSku parameter is ignored. - When the sellerSku parameter is provided, the operation returns inventory summaries for only the specified sellerSku.  Note: The parameters associated with this operation may contain special characters that must be encoded to successfully call the API. To avoid errors with SKUs when encoding URLs, refer to [URL Encoding](https://developer-docs.amazon.com/sp-api/docs/url-encoding).  Usage Plan:  | Rate (requests per second) | Burst | | ---- | ---- | | 2 | 2 |  The x-amzn-RateLimit-Limit response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, see [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits).  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.get_inventory_summaries(granularity_type, granularity_id, marketplace_ids, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str granularity_type: The granularity type for the inventory aggregation level. (required)
        :param str granularity_id: The granularity ID for the inventory aggregation level. (required)
        :param List[str] marketplace_ids: The marketplace ID for the marketplace for which to return inventory summaries. (required)
        :param bool details: true to return inventory summaries with additional summarized inventory details and quantities. Otherwise, returns inventory summaries only (default value).
        :param datetime start_date_time: A start date and time in ISO8601 format. If specified, all inventory summaries that have changed since then are returned. You must specify a date and time that is no earlier than 18 months prior to the date and time when you call the API. Note: Changes in inboundWorkingQuantity, inboundShippedQuantity and inboundReceivingQuantity are not detected.
        :param List[str] seller_skus: A list of seller SKUs for which to return inventory summaries. You may specify up to 50 SKUs.
        :param str seller_sku: A single seller SKU used for querying the specified seller SKU inventory summaries.
        :param str next_token: String token returned in the response of your previous request. The string token will expire 30 seconds after being created.
        :return: GetInventorySummariesResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.get_inventory_summaries_with_http_info(granularity_type, granularity_id, marketplace_ids, **kwargs)  # noqa: E501
        else:
            (data) = self.get_inventory_summaries_with_http_info(granularity_type, granularity_id, marketplace_ids, **kwargs)  # noqa: E501
            return data

    def get_inventory_summaries_with_http_info(self, granularity_type, granularity_id, marketplace_ids, **kwargs):  # noqa: E501
        """get_inventory_summaries  # noqa: E501

        Returns a list of inventory summaries. The summaries returned depend on the presence or absence of the startDateTime, sellerSkus and sellerSku parameters:  - All inventory summaries with available details are returned when the startDateTime, sellerSkus and sellerSku parameters are omitted. - When startDateTime is provided, the operation returns inventory summaries that have had changes after the date and time specified. The sellerSkus and sellerSku parameters are ignored. Important: To avoid errors, use both startDateTime and nextToken to get the next page of inventory summaries that have changed after the date and time specified. - When the sellerSkus parameter is provided, the operation returns inventory summaries for only the specified sellerSkus. The sellerSku parameter is ignored. - When the sellerSku parameter is provided, the operation returns inventory summaries for only the specified sellerSku.  Note: The parameters associated with this operation may contain special characters that must be encoded to successfully call the API. To avoid errors with SKUs when encoding URLs, refer to [URL Encoding](https://developer-docs.amazon.com/sp-api/docs/url-encoding).  Usage Plan:  | Rate (requests per second) | Burst | | ---- | ---- | | 2 | 2 |  The x-amzn-RateLimit-Limit response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, see [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits).  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.get_inventory_summaries_with_http_info(granularity_type, granularity_id, marketplace_ids, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str granularity_type: The granularity type for the inventory aggregation level. (required)
        :param str granularity_id: The granularity ID for the inventory aggregation level. (required)
        :param List[str] marketplace_ids: The marketplace ID for the marketplace for which to return inventory summaries. (required)
        :param bool details: true to return inventory summaries with additional summarized inventory details and quantities. Otherwise, returns inventory summaries only (default value).
        :param datetime start_date_time: A start date and time in ISO8601 format. If specified, all inventory summaries that have changed since then are returned. You must specify a date and time that is no earlier than 18 months prior to the date and time when you call the API. Note: Changes in inboundWorkingQuantity, inboundShippedQuantity and inboundReceivingQuantity are not detected.
        :param List[str] seller_skus: A list of seller SKUs for which to return inventory summaries. You may specify up to 50 SKUs.
        :param str seller_sku: A single seller SKU used for querying the specified seller SKU inventory summaries.
        :param str next_token: String token returned in the response of your previous request. The string token will expire 30 seconds after being created.
        :return: GetInventorySummariesResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['granularity_type', 'granularity_id', 'marketplace_ids', 'details', 'start_date_time', 'seller_skus', 'seller_sku', 'next_token']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in six.iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method get_inventory_summaries" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'granularity_type' is set
        if self.api_client.client_side_validation and ('granularity_type' not in params or
                                                       params['granularity_type'] is None):  # noqa: E501
            raise ValueError("Missing the required parameter `granularity_type` when calling `get_inventory_summaries`")  # noqa: E501
        # verify the required parameter 'granularity_id' is set
        if self.api_client.client_side_validation and ('granularity_id' not in params or
                                                       params['granularity_id'] is None):  # noqa: E501
            raise ValueError("Missing the required parameter `granularity_id` when calling `get_inventory_summaries`")  # noqa: E501
        # verify the required parameter 'marketplace_ids' is set
        if self.api_client.client_side_validation and ('marketplace_ids' not in params or
                                                       params['marketplace_ids'] is None):  # noqa: E501
            raise ValueError("Missing the required parameter `marketplace_ids` when calling `get_inventory_summaries`")  # noqa: E501

        if self.api_client.client_side_validation and ('marketplace_ids' in params and
                                            len(params['marketplace_ids']) > 1):
            raise ValueError("Invalid value for parameter `marketplace_ids` when calling `get_inventory_summaries`, number of items must be less than or equal to `1`")  # noqa: E501
        if self.api_client.client_side_validation and ('seller_skus' in params and
                                            len(params['seller_skus']) > 50):
            raise ValueError("Invalid value for parameter `seller_skus` when calling `get_inventory_summaries`, number of items must be less than or equal to `50`")  # noqa: E501
        collection_formats = {}

        path_params = {}

        query_params = []
        if 'details' in params:
            query_params.append(('details', params['details']))  # noqa: E501
        if 'granularity_type' in params:
            query_params.append(('granularityType', params['granularity_type']))  # noqa: E501
        if 'granularity_id' in params:
            query_params.append(('granularityId', params['granularity_id']))  # noqa: E501
        if 'start_date_time' in params:
            query_params.append(('startDateTime', params['start_date_time']))  # noqa: E501
        if 'seller_skus' in params:
            query_params.append(('sellerSkus', params['seller_skus']))  # noqa: E501
            collection_formats['sellerSkus'] = 'csv'  # noqa: E501
        if 'seller_sku' in params:
            query_params.append(('sellerSku', params['seller_sku']))  # noqa: E501
        if 'next_token' in params:
            query_params.append(('nextToken', params['next_token']))  # noqa: E501
        if 'marketplace_ids' in params:
            query_params.append(('marketplaceIds', params['marketplace_ids']))  # noqa: E501
            collection_formats['marketplaceIds'] = 'csv'  # noqa: E501

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json'])  # noqa: E501

        # Authentication setting
        auth_settings = []  # noqa: E501

        return self.api_client.call_api(
            '/fba/inventory/v1/summaries', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='GetInventorySummariesResponse',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats, api_models_module=self.api_models_module)
