# coding: utf-8

"""
    Selling Partner API for FBA Inbound Eligibilty

    With the FBA Inbound Eligibility API, you can build applications that let sellers get eligibility previews for items before shipping them to Amazon's fulfillment centers. With this API you can find out if an item is eligible for inbound shipment to Amazon's fulfillment centers in a specific marketplace. You can also find out if an item is eligible for using the manufacturer barcode for FBA inventory tracking. Sellers can use this information to inform their decisions about which items to ship Amazon's fulfillment centers.

    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 FbaInboundEligibilityApi(object):
    """NOTE: This class is auto generated by the openapi generator.

    Do not edit the class manually.
    """

    api_models_module = "spapi.models.fba_eligibility_v1"

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

    def get_item_eligibility_preview(self, asin, program, **kwargs):  # noqa: E501
        """get_item_eligibility_preview  # noqa: E501

        This operation gets an eligibility preview for an item that you specify. You can specify the type of eligibility preview that you want (INBOUND or COMMINGLING). For INBOUND previews, you can specify the marketplace in which you want to determine the item's eligibility.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 1 |  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-in-the-sp-api).  # 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_item_eligibility_preview(asin, program, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str asin: The ASIN of the item for which you want an eligibility preview. (required)
        :param str program: The program that you want to check eligibility against. (required)
        :param List[str] marketplace_ids: The identifier for the marketplace in which you want to determine eligibility. Required only when program=INBOUND.
        :return: GetItemEligibilityPreviewResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.get_item_eligibility_preview_with_http_info(asin, program, **kwargs)  # noqa: E501
        else:
            (data) = self.get_item_eligibility_preview_with_http_info(asin, program, **kwargs)  # noqa: E501
            return data

    def get_item_eligibility_preview_with_http_info(self, asin, program, **kwargs):  # noqa: E501
        """get_item_eligibility_preview  # noqa: E501

        This operation gets an eligibility preview for an item that you specify. You can specify the type of eligibility preview that you want (INBOUND or COMMINGLING). For INBOUND previews, you can specify the marketplace in which you want to determine the item's eligibility.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 1 |  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-in-the-sp-api).  # 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_item_eligibility_preview_with_http_info(asin, program, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str asin: The ASIN of the item for which you want an eligibility preview. (required)
        :param str program: The program that you want to check eligibility against. (required)
        :param List[str] marketplace_ids: The identifier for the marketplace in which you want to determine eligibility. Required only when program=INBOUND.
        :return: GetItemEligibilityPreviewResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['asin', 'program', 'marketplace_ids']  # 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_item_eligibility_preview" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'asin' is set
        if self.api_client.client_side_validation and ('asin' not in params or
                                                       params['asin'] is None):  # noqa: E501
            raise ValueError("Missing the required parameter `asin` when calling `get_item_eligibility_preview`")  # noqa: E501
        # verify the required parameter 'program' is set
        if self.api_client.client_side_validation and ('program' not in params or
                                                       params['program'] is None):  # noqa: E501
            raise ValueError("Missing the required parameter `program` when calling `get_item_eligibility_preview`")  # 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_item_eligibility_preview`, number of items must be less than or equal to `1`")  # noqa: E501
        collection_formats = {}

        path_params = {}

        query_params = []
        if 'marketplace_ids' in params:
            query_params.append(('marketplaceIds', params['marketplace_ids']))  # noqa: E501
            collection_formats['marketplaceIds'] = 'csv'  # noqa: E501
        if 'asin' in params:
            query_params.append(('asin', params['asin']))  # noqa: E501
        if 'program' in params:
            query_params.append(('program', params['program']))  # 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', 'ItemEligibilityPreview'])  # noqa: E501

        # Authentication setting
        auth_settings = []  # noqa: E501

        return self.api_client.call_api(
            '/fba/inbound/v1/eligibility/itemPreview', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='GetItemEligibilityPreviewResponse',  # 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)
