# coding: utf-8

"""
    Buy Marketing Api

    The Marketing API retrieves eBay products based on a metric, such as Best Selling, as well as products that were also bought and also viewed.  # noqa: E501

    OpenAPI spec version: 1.1.0
    
    Generated by: https://github.com/swagger-api/swagger-codegen.git
"""

from __future__ import absolute_import

import re  # noqa: F401

# python 2 and python 3 compatibility library
import six

from ...buy_marketing.api_client import ApiClient


class MostWatchedItemsApi(object):
    """NOTE: This class is auto generated by the swagger code generator program.

    Do not edit the class manually.
    Ref: https://github.com/swagger-api/swagger-codegen
    """

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

    def get_most_watched_items(self, category_id, **kwargs):  # noqa: E501
        """get_most_watched_items  # noqa: E501

        This method retrieves items with the highest watch counts in a specific category.<br><br> The leaf category for which to retrieve items with the highest watch counts is specified by its <b>category_id</b> value. Up to 50 items can be returned for a specific category using this method. The number of items to return using this method can be specified through the <b>max_result</b> query parameter. If this parameter is not used, the top 20 most watched items will be returned for the specified category.<br><br> A successful call returns details about the most watched items in a specific category, such as the watch count, current price, shipping cost, and basic information about the listing. Returned items are ranked in descending order with the highest watch count appearing first.  # 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_most_watched_items(category_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str category_id: This query parameter can be used to specify the leaf category from which to retrieve most watched items.<br /> <br />The list of eBay category IDs is not published and category IDs are not all the same across all the eBay marketplaces. You can use the following techniques to find a category by site: <ul> <li>Use the <a href=\"https://pages.ebay.com/sellerinformation/news/categorychanges.html\" target=\"_blank\">Category Changes</a> page.</li> <li>Use the <b>Taxonomy API</b>. For details on using this API, see <a href=\"/api-docs/buy/buy-categories.html\" target=\"_blank\">Get Categories for Buy APIs</a>. </li>  <li>Use the following <b>Browse API</b> method to get the <b> dominantCategoryId</b> for an item:<pre>/buy/browse/v1/item_summary/search?q=<i> keyword</i>&fieldgroups=ASPECT_REFINEMENTS</pre></li></ul><br><span class=\"tablenote\"><b>Note:</b> If no category ID is input though this parameter, category <code>9355</code> will be used by default.</span><br><b> Maximum: </b> 1 (required)
        :param str accept_language: This header is used to indicate the natural language and locale preferred by the user for the response.<br><br>This header is required when targeting a specific locale of a marketplace that supports multiple locales. For example:<ul><li>When targeting the French locale of the Belgium marketplace, it is required to pass in <code>fr-BE</code> to specify this. If this locale is not specified, the language will default to Dutch.</li><li>When targeting the French locale of the Canadian marketplace, it is required to pass in <code>fr-CA</code> to specify this. If this locale is not specified, the language will default to English.</li></ul>
        :param str max_results: This query parameter can be used to specify the maximum number of most watched items to return from the specified category.<br><br><b>Default value:</b> 20<br><br><b>Min value:</b> 1<br><br><b>Max value:</b> 50
        :param str x_ebay_c_enduserctx: This header can be used to pass in affiliate credentials to return item affiliate information. For more information, see <a href=\"/api-docs/buy/static/api-browse.html#affiliate-header\" target=\"_blank \">Header for affiliate information.</a>
        :param str x_ebay_c_marketplace_id: This header identifies the seller's eBay marketplace. It is required for all marketplaces outside of the US.<br><br><span class=\"tablenote\"><b>Note:</b> If the marketplace ID value is invalid or missing, the default value of <code>EBAY_US</code> is used.</span><br>See <a href=\"/api-docs/buy/marketing_v1/types/ba:MarketplaceIdEnum \" target=\"_blank\">MarketplaceIdEnum</a> for a list of supported marketplaces.<br><br><b>Default:</b> <code>EBAY_US</code>
        :return: MostWatchedItemsResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        if '_return_http_data_only' not in kwargs:  # ebay_rest patch
            kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.get_most_watched_items_with_http_info(category_id, **kwargs)  # noqa: E501
        else:
            (data) = self.get_most_watched_items_with_http_info(category_id, **kwargs)  # noqa: E501
            return data

    def get_most_watched_items_with_http_info(self, category_id, **kwargs):  # noqa: E501
        """get_most_watched_items  # noqa: E501

        This method retrieves items with the highest watch counts in a specific category.<br><br> The leaf category for which to retrieve items with the highest watch counts is specified by its <b>category_id</b> value. Up to 50 items can be returned for a specific category using this method. The number of items to return using this method can be specified through the <b>max_result</b> query parameter. If this parameter is not used, the top 20 most watched items will be returned for the specified category.<br><br> A successful call returns details about the most watched items in a specific category, such as the watch count, current price, shipping cost, and basic information about the listing. Returned items are ranked in descending order with the highest watch count appearing first.  # 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_most_watched_items_with_http_info(category_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str category_id: This query parameter can be used to specify the leaf category from which to retrieve most watched items.<br /> <br />The list of eBay category IDs is not published and category IDs are not all the same across all the eBay marketplaces. You can use the following techniques to find a category by site: <ul> <li>Use the <a href=\"https://pages.ebay.com/sellerinformation/news/categorychanges.html\" target=\"_blank\">Category Changes</a> page.</li> <li>Use the <b>Taxonomy API</b>. For details on using this API, see <a href=\"/api-docs/buy/buy-categories.html\" target=\"_blank\">Get Categories for Buy APIs</a>. </li>  <li>Use the following <b>Browse API</b> method to get the <b> dominantCategoryId</b> for an item:<pre>/buy/browse/v1/item_summary/search?q=<i> keyword</i>&fieldgroups=ASPECT_REFINEMENTS</pre></li></ul><br><span class=\"tablenote\"><b>Note:</b> If no category ID is input though this parameter, category <code>9355</code> will be used by default.</span><br><b> Maximum: </b> 1 (required)
        :param str accept_language: This header is used to indicate the natural language and locale preferred by the user for the response.<br><br>This header is required when targeting a specific locale of a marketplace that supports multiple locales. For example:<ul><li>When targeting the French locale of the Belgium marketplace, it is required to pass in <code>fr-BE</code> to specify this. If this locale is not specified, the language will default to Dutch.</li><li>When targeting the French locale of the Canadian marketplace, it is required to pass in <code>fr-CA</code> to specify this. If this locale is not specified, the language will default to English.</li></ul>
        :param str max_results: This query parameter can be used to specify the maximum number of most watched items to return from the specified category.<br><br><b>Default value:</b> 20<br><br><b>Min value:</b> 1<br><br><b>Max value:</b> 50
        :param str x_ebay_c_enduserctx: This header can be used to pass in affiliate credentials to return item affiliate information. For more information, see <a href=\"/api-docs/buy/static/api-browse.html#affiliate-header\" target=\"_blank \">Header for affiliate information.</a>
        :param str x_ebay_c_marketplace_id: This header identifies the seller's eBay marketplace. It is required for all marketplaces outside of the US.<br><br><span class=\"tablenote\"><b>Note:</b> If the marketplace ID value is invalid or missing, the default value of <code>EBAY_US</code> is used.</span><br>See <a href=\"/api-docs/buy/marketing_v1/types/ba:MarketplaceIdEnum \" target=\"_blank\">MarketplaceIdEnum</a> for a list of supported marketplaces.<br><br><b>Default:</b> <code>EBAY_US</code>
        :return: MostWatchedItemsResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['category_id', 'accept_language', 'max_results', 'x_ebay_c_enduserctx', 'x_ebay_c_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 get_most_watched_items" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'category_id' is set
        if ('category_id' not in params or
                params['category_id'] is None):
            raise ValueError("Missing the required parameter `category_id` when calling `get_most_watched_items`")  # noqa: E501

        collection_formats = {}

        path_params = {}

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

        header_params = {}
        if 'accept_language' in params:
            header_params['Accept-Language'] = params['accept_language']  # noqa: E501
        if 'x_ebay_c_enduserctx' in params:
            header_params['X-EBAY-C-ENDUSERCTX'] = params['x_ebay_c_enduserctx']  # noqa: E501
        if 'x_ebay_c_marketplace_id' in params:
            header_params['X-EBAY-C-MARKETPLACE-ID'] = params['x_ebay_c_marketplace_id']  # noqa: E501

        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 = ['api_auth']  # noqa: E501

        return self.api_client.call_api(
            '/most_watched_items', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='MostWatchedItemsResponse',  # 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)
