# coding: utf-8

"""
    Buy Feed API

    The Feed API provides the ability to download TSV_GZIP feed files containing eBay items and an hourly snapshot file for a specific category, date, and marketplace.<br /><br />In addition to the API, there is an open-source Feed SDK written in Java that downloads, combines files into a single file when needed, and unzips the entire feed file. It also lets you specify field filters to curate the items in the file.  # noqa: E501

    OpenAPI spec version: v1.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_feed.api_client import ApiClient


class FeedTypeApi(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_feed_type(self, feed_type_id, **kwargs):  # noqa: E501
        """get_feed_type  # noqa: E501

        Use the <b>getFeedType</b> method to obtain the details about a particular feed type to determine its applicability to your needs.<br /><br />With the response, you can compare the eBay marketplaces and categories with the eBay marketplaces and categories that your application is enabled to access. By making these comparisons, you can avoid attempting to download feed files that you do not have access to.<br /><br /><span class=\"tablenote\"><span style=\"color:#004680\"><strong>Note:</strong></span> For a list of supported sites and other restrictions, see <a href=\"/api-docs/buy/feed/overview.html#API\">API Restrictions</a>.</span>  # 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_feed_type(feed_type_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str feed_type_id: This path parameter specifies the unique identifier for the feed type to be used as a search filter.<br /><br />Use the <a href=\"/api-docs/buy/feed/v1/resources/feed_type/methods/getFeedTypes\" target=\"_blank\">getFeedTypes</a> method to identify available feed types.<br /><br /><span class=\"tablenote\"><span style=\"color:#004680\"><strong>Note:</strong></span> Refer to <a href=\"/api-docs/buy/feed/v1/static/overview.html#feed-types\" target=\"_blank\">Supported feed types</a> to learn more about the feed types supported by the Feed API.</span> (required)
        :return: FeedType
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.get_feed_type_with_http_info(feed_type_id, **kwargs)  # noqa: E501
        else:
            (data) = self.get_feed_type_with_http_info(feed_type_id, **kwargs)  # noqa: E501
            return data

    def get_feed_type_with_http_info(self, feed_type_id, **kwargs):  # noqa: E501
        """get_feed_type  # noqa: E501

        Use the <b>getFeedType</b> method to obtain the details about a particular feed type to determine its applicability to your needs.<br /><br />With the response, you can compare the eBay marketplaces and categories with the eBay marketplaces and categories that your application is enabled to access. By making these comparisons, you can avoid attempting to download feed files that you do not have access to.<br /><br /><span class=\"tablenote\"><span style=\"color:#004680\"><strong>Note:</strong></span> For a list of supported sites and other restrictions, see <a href=\"/api-docs/buy/feed/overview.html#API\">API Restrictions</a>.</span>  # 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_feed_type_with_http_info(feed_type_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str feed_type_id: This path parameter specifies the unique identifier for the feed type to be used as a search filter.<br /><br />Use the <a href=\"/api-docs/buy/feed/v1/resources/feed_type/methods/getFeedTypes\" target=\"_blank\">getFeedTypes</a> method to identify available feed types.<br /><br /><span class=\"tablenote\"><span style=\"color:#004680\"><strong>Note:</strong></span> Refer to <a href=\"/api-docs/buy/feed/v1/static/overview.html#feed-types\" target=\"_blank\">Supported feed types</a> to learn more about the feed types supported by the Feed API.</span> (required)
        :return: FeedType
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['feed_type_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_feed_type" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'feed_type_id' is set
        if ('feed_type_id' not in params or
                params['feed_type_id'] is None):
            raise ValueError("Missing the required parameter `feed_type_id` when calling `get_feed_type`")  # noqa: E501

        collection_formats = {}

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

        query_params = []

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

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

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

        <p>Use the <b>getFeedTypes</b> method to obtain the details about one or more feed types that are available to be downloaded. If no query parameters are used, all possible feed types are returned.</p>You can filter your search by adding <b>feed_scope</b> and/or <b>marketplace_ids</b> parameters to the URI.</p><p>For instance, a call using <code>GET https://api.ebay.com/buy/feed/v1/feed_type</code> will return all available feed files. A call using <code> GET https://api.ebay.com/buy/feed/v1/feed_type?feed_scope=DAILY&marketplace_ids=EBAY_US</code> will limit the returned list to daily feed files available from the  US marketplace.</p><h3><b>Restrictions </b></h3><p>For a list of supported sites and other restrictions, see <a href=\"/api-docs/buy/feed/v1/overview.html#API\">API Restrictions</a>.</p>  # 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_feed_types(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str continuation_token: The server returns this token to the web client when the responses received require multiple pages to display. The web client sends this token back to the server to get the next page of results.
        :param str feed_scope: This query parameter specifies the frequency with which the feed file is made available (<code>HOURLY</code>, <code>DAILY</code>, <code>WEEKLY</code>).<br><br><span class=\"tablenote\"><b>Note:</b> Currently only <code>DAILY</code> and <code>HOURLY</code> are supported.</span>
        :param str limit: Specifies the number of records to show in the current response.<br /><br /><b>Default:</b> 20<br /><br /><b>Minimum:</b> 20<br /><br /><b>Maximum:</b> 100
        :param str marketplace_ids: Use this query parameter to limit marketplaces you want to see in the result set.<br><br>To search for multiple marketplaces at once, list them in the URI separated by commas.<br /><br /><b>Example:</b><br><code>GET https://api.ebay.com/buy/feed/v1/feedtype?marketplaceids=EBAY_FR,EBAY_AU</code>.<br /><br />See <a href=\"/api-docs/buy/feed/v1/types/bas:MarketplaceIdEnum\" target=\"_blank\">MarketplaceIdEnum</a> for supported values.
        :return: FeedTypeSearchResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.get_feed_types_with_http_info(**kwargs)  # noqa: E501
        else:
            (data) = self.get_feed_types_with_http_info(**kwargs)  # noqa: E501
            return data

    def get_feed_types_with_http_info(self, **kwargs):  # noqa: E501
        """get_feed_types  # noqa: E501

        <p>Use the <b>getFeedTypes</b> method to obtain the details about one or more feed types that are available to be downloaded. If no query parameters are used, all possible feed types are returned.</p>You can filter your search by adding <b>feed_scope</b> and/or <b>marketplace_ids</b> parameters to the URI.</p><p>For instance, a call using <code>GET https://api.ebay.com/buy/feed/v1/feed_type</code> will return all available feed files. A call using <code> GET https://api.ebay.com/buy/feed/v1/feed_type?feed_scope=DAILY&marketplace_ids=EBAY_US</code> will limit the returned list to daily feed files available from the  US marketplace.</p><h3><b>Restrictions </b></h3><p>For a list of supported sites and other restrictions, see <a href=\"/api-docs/buy/feed/v1/overview.html#API\">API Restrictions</a>.</p>  # 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_feed_types_with_http_info(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str continuation_token: The server returns this token to the web client when the responses received require multiple pages to display. The web client sends this token back to the server to get the next page of results.
        :param str feed_scope: This query parameter specifies the frequency with which the feed file is made available (<code>HOURLY</code>, <code>DAILY</code>, <code>WEEKLY</code>).<br><br><span class=\"tablenote\"><b>Note:</b> Currently only <code>DAILY</code> and <code>HOURLY</code> are supported.</span>
        :param str limit: Specifies the number of records to show in the current response.<br /><br /><b>Default:</b> 20<br /><br /><b>Minimum:</b> 20<br /><br /><b>Maximum:</b> 100
        :param str marketplace_ids: Use this query parameter to limit marketplaces you want to see in the result set.<br><br>To search for multiple marketplaces at once, list them in the URI separated by commas.<br /><br /><b>Example:</b><br><code>GET https://api.ebay.com/buy/feed/v1/feedtype?marketplaceids=EBAY_FR,EBAY_AU</code>.<br /><br />See <a href=\"/api-docs/buy/feed/v1/types/bas:MarketplaceIdEnum\" target=\"_blank\">MarketplaceIdEnum</a> for supported values.
        :return: FeedTypeSearchResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['continuation_token', 'feed_scope', 'limit', '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_feed_types" % key
                )
            params[key] = val
        del params['kwargs']

        collection_formats = {}

        path_params = {}

        query_params = []
        if 'continuation_token' in params:
            query_params.append(('continuation_token', params['continuation_token']))  # noqa: E501
        if 'feed_scope' in params:
            query_params.append(('feed_scope', params['feed_scope']))  # noqa: E501
        if 'limit' in params:
            query_params.append(('limit', params['limit']))  # noqa: E501
        if 'marketplace_ids' in params:
            query_params.append(('marketplace_ids', params['marketplace_ids']))  # 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 = ['api_auth']  # noqa: E501

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