# coding: utf-8

"""
    Selling Partner API for Listings Restrictions

    The Selling Partner API for Listings Restrictions provides programmatic access to restrictions on Amazon catalog listings.  For more information, see the [Listings Restrictions API Use Case Guide](doc:listings-restrictions-api-v2021-08-01-use-case-guide).

    The version of the OpenAPI document: 2021-08-01
    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 ListingsRestrictionsApi(object):
    """NOTE: This class is auto generated by the openapi generator.

    Do not edit the class manually.
    """

    api_models_module = "spapi.models.listings_restrictions_v2021_08_01"

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

    def get_listings_restrictions(self, asin, seller_id, marketplace_ids, **kwargs):  # noqa: E501
        """get_listings_restrictions  # noqa: E501

        Returns listing restrictions for an item in the Amazon Catalog.   **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 5 | 10 |  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 then those shown here. For more information, see [Usage Plans and Rate Limits in the Selling Partner API](doc: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_listings_restrictions(asin, seller_id, marketplace_ids, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str asin: The Amazon Standard Identification Number (ASIN) of the item. (required)
        :param str seller_id: A selling partner identifier, such as a merchant account. (required)
        :param List[str] marketplace_ids: A comma-delimited list of Amazon marketplace identifiers for the request. (required)
        :param str condition_type: The condition used to filter restrictions.
        :param str reason_locale: A locale for reason text localization. When not provided, the default language code of the first marketplace is used. Examples: \"en_US\", \"fr_CA\", \"fr_FR\". Localized messages default to \"en_US\" when a localization is not available in the specified locale.
        :return: RestrictionList
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.get_listings_restrictions_with_http_info(asin, seller_id, marketplace_ids, **kwargs)  # noqa: E501
        else:
            (data) = self.get_listings_restrictions_with_http_info(asin, seller_id, marketplace_ids, **kwargs)  # noqa: E501
            return data

    def get_listings_restrictions_with_http_info(self, asin, seller_id, marketplace_ids, **kwargs):  # noqa: E501
        """get_listings_restrictions  # noqa: E501

        Returns listing restrictions for an item in the Amazon Catalog.   **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 5 | 10 |  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 then those shown here. For more information, see [Usage Plans and Rate Limits in the Selling Partner API](doc: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_listings_restrictions_with_http_info(asin, seller_id, marketplace_ids, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str asin: The Amazon Standard Identification Number (ASIN) of the item. (required)
        :param str seller_id: A selling partner identifier, such as a merchant account. (required)
        :param List[str] marketplace_ids: A comma-delimited list of Amazon marketplace identifiers for the request. (required)
        :param str condition_type: The condition used to filter restrictions.
        :param str reason_locale: A locale for reason text localization. When not provided, the default language code of the first marketplace is used. Examples: \"en_US\", \"fr_CA\", \"fr_FR\". Localized messages default to \"en_US\" when a localization is not available in the specified locale.
        :return: RestrictionList
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['asin', 'seller_id', 'marketplace_ids', 'condition_type', 'reason_locale']  # 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_listings_restrictions" % 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_listings_restrictions`")  # noqa: E501
        # verify the required parameter 'seller_id' is set
        if self.api_client.client_side_validation and ('seller_id' not in params or
                                                       params['seller_id'] is None):  # noqa: E501
            raise ValueError("Missing the required parameter `seller_id` when calling `get_listings_restrictions`")  # 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_listings_restrictions`")  # noqa: E501

        collection_formats = {}

        path_params = {}

        query_params = []
        if 'asin' in params:
            query_params.append(('asin', params['asin']))  # noqa: E501
        if 'condition_type' in params:
            query_params.append(('conditionType', params['condition_type']))  # noqa: E501
        if 'seller_id' in params:
            query_params.append(('sellerId', params['seller_id']))  # noqa: E501
        if 'marketplace_ids' in params:
            query_params.append(('marketplaceIds', params['marketplace_ids']))  # noqa: E501
            collection_formats['marketplaceIds'] = 'csv'  # noqa: E501
        if 'reason_locale' in params:
            query_params.append(('reasonLocale', params['reason_locale']))  # 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(
            '/listings/2021-08-01/restrictions', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='RestrictionList',  # 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)
