# coding: utf-8

"""
     Seller Service Metrics API 

    The <i>Analytics API</i> provides data and information about a seller and their eBay business.  <br><br>The resources and methods in this API let sellers review information on their listing performance, metrics on their customer service performance, and details on their eBay seller performance rating.  <br><br>The three resources in the Analytics API provide the following data and information: <ul><li><b>Customer Service Metric</b> &ndash; Returns benchmark data and a metric rating pertaining to a seller's customer service performance as compared to other seller's in the same peer group.</li> <li><b>Traffic Report</b> &ndash; Returns data and information that shows how buyers are engaging with a seller's listings.</li> <li><b>Seller Standards Profile</b> &ndash; Returns information pertaining to a seller's profile rating.</li></ul> Sellers can use the data and information returned by the various Analytics API methods to determine where they can make improvements to increase sales and how they might improve their seller status as viewed by eBay buyers.  <br><br>For details on using this API, see <a href=\"/api-docs/sell/static/performance/analyzing-performance.html\" title=\"Selling Integration Guide\">Analyzing seller performance</a>.  # noqa: E501

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


class TrafficReportApi(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_traffic_report(self, **kwargs):  # noqa: E501
        """get_traffic_report  # noqa: E501

        This method returns a report that details the user traffic received by a seller's listings. <br><br>A traffic report gives sellers the ability to review how often their listings appeared on eBay, how many times their listings are viewed, and how many purchases were made. The report also returns the report's start and end dates, and the date the information was last updated.  <br><br>For more information, see <a href=\"/api-docs/sell/static/performance/traffic-report.html\" target=\"_blank\">Traffic report details</a>  # 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_traffic_report(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str dimension: This query parameter specifies the <i>dimension</i>, or \"attribute,\" that is applied to the report <b>metric</b>.  <br><br><b>Valid values:</b> <code>DAY</code> or <code>LISTING</code>  <br><br><b>Examples</b> <ul><li>If you specify <code>dimension=DAY</code> and <code>metric=CLICK_THROUGH_RATE</code>, the traffic report contains the number of times an item displayed on a search results page and the buyer clicked through to the View Item page for each day in the date range, as in: <br><code>12-06-17: 32, 12-07-17: 54, ...</code></li> <li>If you specify <code>dimension=LISTING</code> and <code>metric=LISTING_IMPRESSION_STORE</code>, the traffic report contains the number of times that listing appeared on the seller's store during the specified date range. <br><br>For example, <code>LISTING_IMPRESSION_STORE: 157</code> means the item appeared 157 times in the store during the date range.</li><li>If you specify <code>dimension=LISTING</code> without specifying any <b>listing_ids</b> in the parameter filter, the traffic report returned in the response contains a maximum of 200 listings.</li></ul> <!-- Dimension - Enables user to specify input to slice the data that the user is interested in - For example specify listing and days as dimensions to get traffic report for all the sellers listings grouped by listing and days. Refer to DimensionEnum) -->
        :param str filter: This query parameter refines the information returned in the traffic report. <br><p><span class=\"tablenote\"><b>Note: </b> URL encode all the values you supply in the <b>filter</b> parameter. See <b>URL encoding query parameter values</b> as described in <a href=\"/api-docs/static/rest-request-components.html#parameters\" target=\"_blank\">URL parameters</a>.</span></p>Configure the following properties of the <b>filter</b> parameter to tune the traffic report to your needs: <ul> <li><b>date_range</b> <br>Limits the report to the specified range of dates. This value can be formatted in one of two ways depending on the user's time zone.<ul><li><b>For America/Los_Angeles time zone</b>, input the date range using <code>YYMMDD</code> format. As this is the default time zone used for timestamps in the report, the time zone does not need to be specified. Enclose the earliest date and end date for the report in brackets (\"<code>[ ]</code>\"), as follows:<br><br><code>[YYYYMMDD..YYYYMMDD]</code><br><br>For example:<br><pre>[20240101..20240131]</pre></li><li><b>For all other time zones</b>, input the date range using <a href=\"https://www.iso.org/iso-8601-date-and-time-format.html\" target=\"_blank\">ISO 8601</a> format, and specify the time zone using a UTC offset. A time zone offset is a positive or negative value that represents the number of hours a time zone is from UTC (see <a href=\"https://www.utctime.net/utc-time-zone-converter\" target=\"_blank\">UTC Time Zone Converter</a> for offset values for your time zone). Enclose the earliest date and end date for the report in brackets (\"<code>[ ]</code>\"), as follows:<br><br><code>[yyyy-MM-dd'T'HH:mm:ss.SSS+|-hh:mm..yyyy-MM-dd'T'HH:mm:ss.SSS+|-hh:mm]</code><br><br>For example:<br><pre>[2024-01-01T02:00:00.000-05:00..2024-01-31T02:00:00.000-05:00]</pre><span class=\"tablenote\"><b>Note:</b> All time values entered in this format will be dropped, and will be replaced with <code>00:00:00.000</code> for <b>startDate</b> and <code>23:59:59.000</code> for <b>endDate</b> in the response body.</span></li></ul>The maximum range between the start and end dates is 90 days, and the earliest start date you can specify is two years prior to the current date, which is defined as 730 days (365 &#42; 2), not accounting for Leap Year.<br><br><a name=\"lastUDate\"></a>The last date for which traffic data exists is a value called <b>lastUpdatedDate</b>. eBay returns an error if you specify a date range greater than 90 days, or the start date is after the lastUpdatedDate. If the specified end date is beyond the lastUpdatedDate, eBay returns data up to the lastUpdatedDate.<br><br><b>Required:</b> Always</li> <li><b>listing_ids</b> <br>This filter limits the results to only the supplied list of <b>listingId</b> values. <br><br><span class=\"tablenote\"><b>Note:</b> If you specify <code>dimension=LISTING</code> without specifying any listing_ids in this parameter, the traffic report returned in the response contains a maximum of 200 listings.</span><br>You can specify to 200 different <b>listingId</b> values. Enclose the list of IDs with curly braces (\"<code>{ }</code>\"), and separate multiple values with a pipe character (\"<code>|</code>\").  <br><br>This filter only returns data for listings that have been either active or sold in last 90 days, and any unsold listings in the last 30 days. All listings must be the seller's and they  must be listed on the marketplace specified by the <b>marketplace_ids</b> filter argument.</li> <li><b>marketplace_ids</b> <br>This filter limits the report to seller data related to only the specified marketplace ID (currently the filter allows only a single marketplace ID). Enclose the marketplace ID in curly braces (\"<code>{ }</code>\").  <br><br><b>Valid values:</b> <ul class=\"compact\"><li><code>EBAY_AU</code></li> <li><code>EBAY_DE</code></li><li><code>EBAY_ES</code></li><li><code>EBAY_FR</code></li> <li><code>EBAY_GB</code></li> <li><code>EBAY_IT</code></li><li><code>EBAY_US</code></li> <li><code>EBAY_MOTORS_US</code></li></ul> <br><b>Required if</b> you set the <b>dimension</b> parameter to <code>DAY</code>.</li></ul> <br><b>Example filter parameter</b> <br>The following example shows how to configure the <b>filter</b> parameter with the <b>marketplace_ids</b> and <b>date_range</b> filters: <p><code>filter=marketplace_ids:{EBAY_US},date_range:[20170601..20170828]</code><br><br>Encoding this portion of the query parameter sample yields: <p><code>filter=marketplace_ids:%7BEBAY_US%7D,date_range:%5B20230601..20230828%5D</code> </p><br>See <a href=\" /api-docs/sell/analytics/resources/traffic_report/methods/getTrafficReport#h2-samples\">samples</a> for additional examples.<!-- **Filter results based on the specified filter parameters- window_days (WindowDaysEnum), date_range, marketplace_id (MarketplaceIdEnum - Only EBAY_US, EBAY_MOTORS_US, EBAY_GB, EBAY_AU, EBAY_DE are supported), listing_ids, traffic_source (Takes a list. Supported values: ORGANIC, PROMOTED_LISTINGS). Valid filters come from QueryParamEnum --> For implementation help, refer to eBay API documentation at https://developer.ebay.com/api-docs/sell/analytics/types/csb:FilterField
        :param str metric: <a name=\"metrics\"></a>This query parameter specifies the metrics you want covered in the report. <br><p><span class=\"tablenote\"><b>Note: </b> Unlike names for parameters and enumerated values, metric values are not case sensitive.</span></p><b>Valid values:</b><ul>    <li><a href=\"/api-docs/sell/static/performance/traffic-report.html#click_through_rate\" target=\"_blank\">CLICK_THROUGH_RATE</a></li>    <li><a href=\"/api-docs/sell/static/performance/traffic-report.html#listing_impression_search_results_page\" target=\"_blank\">LISTING_IMPRESSION_SEARCH_RESULTS_PAGE</a> </li>    <li><a href=\"/api-docs/sell/static/performance/traffic-report.html#listing_impression_store\" target=\"_blank\">LISTING_IMPRESSION_STORE</a></li>    <li><a href=\"/api-docs/sell/static/performance/traffic-report.html#listing_impression_total\" target=\"_blank\">LISTING_IMPRESSION_TOTAL</a></li>    <li><a href=\"/api-docs/sell/static/performance/traffic-report.html#listing_views_source_direct\" target=\"_blank\">LISTING_VIEWS_SOURCE_DIRECT</a></li>    <li><a href=\"/api-docs/sell/static/performance/traffic-report.html#listing_views_source_off_ebay\" target=\"_blank\">LISTING_VIEWS_SOURCE_OFF_EBAY</a></li>    <li><a href=\"/api-docs/sell/static/performance/traffic-report.html#listing_views_source_other_ebay\" target=\"_blank\">LISTING_VIEWS_SOURCE_OTHER_EBAY</a></li>    <li><a href=\"/api-docs/sell/static/performance/traffic-report.html#listing_views_source_search_results_page\" target=\"_blank\">LISTING_VIEWS_SOURCE_SEARCH_RESULTS_PAGE</a></li>    <li><a href=\"/api-docs/sell/static/performance/traffic-report.html#listing_views_source_store\" target=\"_blank\">LISTING_VIEWS_SOURCE_STORE</a></li>    <li><a href=\"/api-docs/sell/static/performance/traffic-report.html#listing_views_total\" target=\"_blank\">LISTING_VIEWS_TOTAL</a></li>    <li><a href=\"/api-docs/sell/static/performance/traffic-report.html#sales_conversion_rate\" target=\"_blank\">SALES_CONVERSION_RATE</a></li>    <li><a href=\"/api-docs/sell/static/performance/traffic-report.html#total_impression_total\" target=\"_blank\">TOTAL_IMPRESSION_TOTAL</a></li>    <li><a href=\"/api-docs/sell/static/performance/traffic-report.html#transaction\" target=\"_blank\">TRANSACTION</a></li></ul>Specify a comma-separated list of the metrics to include them in the report. See <a href=\"/api-docs/sell/static/performance/traffic-report.html#metric-parameters\" target=\"_blank\">Using different metric parameters</a> for more information including detailed metric descriptions and localized names.<!-- Metric - Lets the user specify the list of fields that they would like to see in the report. Allowed values: CLICK_THROUGH_RATE, LISTING_IMPRESSION_SEARCH_RESULTS_PAGE, LISTING_IMPRESSION_STORE, LISTING_IMPRESSION_TOTAL, LISTING_VIEWS_SOURCE_DIRECT, LISTING_VIEWS_SOURCE_OFF_EBAY, LISTING_VIEWS_SOURCE_OTHER_EBAY, LISTING_VIEWS_SOURCE_SEARCH_RESULTS_PAGE, LISTING_VIEWS_SOURCE_STORE, LISTING_VIEWS_TOTAL, SALES_CONVERSION_RATE (DataMetricEnum), TOTAL_IMPRESSION_TOTAL, TRANSACTION -->
        :param str sort: This query parameter sorts the report on the specified metric.  <br><br>You can only specify a single metric in the sort parameter and the specified metric must be included in the configuration of the report's <a href=\"#metrics\">metric</a> parameter.  <br><br>Sorting is helpful when you want to review how a specific metric is performing, such as the CLICK_THROUGH_RATE.  <br><br>Most reports can be sorted in ascending or descending order. Precede the value of a descending-order request with a minus sign (\"<code>-</code>\"), for example: <code>sort=-CLICK_THROUGH_RATE</code>.<br /><br /><span class=\"tablenote\"><b>Note:</b> There are a couple of constraints on sorting the report by different metrics:<ul><li>Sorting on the <code>SALES_CONVERSION_RATE</code> metric is not supported</li><li>The <code>TRANSACTION</code> metric can only be sorted in the descending order (sorting in the ascending order is not supported).</li></ul></span> <!-- Sort order for a collection of resources: Specify the metric value to be sorted. Allowed values are from DataMetricEnum --> For implementation help, refer to eBay API documentation at https://developer.ebay.com/api-docs/sell/analytics/types/csb:SortField
        :return: Report
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.get_traffic_report_with_http_info(**kwargs)  # noqa: E501
        else:
            (data) = self.get_traffic_report_with_http_info(**kwargs)  # noqa: E501
            return data

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

        This method returns a report that details the user traffic received by a seller's listings. <br><br>A traffic report gives sellers the ability to review how often their listings appeared on eBay, how many times their listings are viewed, and how many purchases were made. The report also returns the report's start and end dates, and the date the information was last updated.  <br><br>For more information, see <a href=\"/api-docs/sell/static/performance/traffic-report.html\" target=\"_blank\">Traffic report details</a>  # 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_traffic_report_with_http_info(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str dimension: This query parameter specifies the <i>dimension</i>, or \"attribute,\" that is applied to the report <b>metric</b>.  <br><br><b>Valid values:</b> <code>DAY</code> or <code>LISTING</code>  <br><br><b>Examples</b> <ul><li>If you specify <code>dimension=DAY</code> and <code>metric=CLICK_THROUGH_RATE</code>, the traffic report contains the number of times an item displayed on a search results page and the buyer clicked through to the View Item page for each day in the date range, as in: <br><code>12-06-17: 32, 12-07-17: 54, ...</code></li> <li>If you specify <code>dimension=LISTING</code> and <code>metric=LISTING_IMPRESSION_STORE</code>, the traffic report contains the number of times that listing appeared on the seller's store during the specified date range. <br><br>For example, <code>LISTING_IMPRESSION_STORE: 157</code> means the item appeared 157 times in the store during the date range.</li><li>If you specify <code>dimension=LISTING</code> without specifying any <b>listing_ids</b> in the parameter filter, the traffic report returned in the response contains a maximum of 200 listings.</li></ul> <!-- Dimension - Enables user to specify input to slice the data that the user is interested in - For example specify listing and days as dimensions to get traffic report for all the sellers listings grouped by listing and days. Refer to DimensionEnum) -->
        :param str filter: This query parameter refines the information returned in the traffic report. <br><p><span class=\"tablenote\"><b>Note: </b> URL encode all the values you supply in the <b>filter</b> parameter. See <b>URL encoding query parameter values</b> as described in <a href=\"/api-docs/static/rest-request-components.html#parameters\" target=\"_blank\">URL parameters</a>.</span></p>Configure the following properties of the <b>filter</b> parameter to tune the traffic report to your needs: <ul> <li><b>date_range</b> <br>Limits the report to the specified range of dates. This value can be formatted in one of two ways depending on the user's time zone.<ul><li><b>For America/Los_Angeles time zone</b>, input the date range using <code>YYMMDD</code> format. As this is the default time zone used for timestamps in the report, the time zone does not need to be specified. Enclose the earliest date and end date for the report in brackets (\"<code>[ ]</code>\"), as follows:<br><br><code>[YYYYMMDD..YYYYMMDD]</code><br><br>For example:<br><pre>[20240101..20240131]</pre></li><li><b>For all other time zones</b>, input the date range using <a href=\"https://www.iso.org/iso-8601-date-and-time-format.html\" target=\"_blank\">ISO 8601</a> format, and specify the time zone using a UTC offset. A time zone offset is a positive or negative value that represents the number of hours a time zone is from UTC (see <a href=\"https://www.utctime.net/utc-time-zone-converter\" target=\"_blank\">UTC Time Zone Converter</a> for offset values for your time zone). Enclose the earliest date and end date for the report in brackets (\"<code>[ ]</code>\"), as follows:<br><br><code>[yyyy-MM-dd'T'HH:mm:ss.SSS+|-hh:mm..yyyy-MM-dd'T'HH:mm:ss.SSS+|-hh:mm]</code><br><br>For example:<br><pre>[2024-01-01T02:00:00.000-05:00..2024-01-31T02:00:00.000-05:00]</pre><span class=\"tablenote\"><b>Note:</b> All time values entered in this format will be dropped, and will be replaced with <code>00:00:00.000</code> for <b>startDate</b> and <code>23:59:59.000</code> for <b>endDate</b> in the response body.</span></li></ul>The maximum range between the start and end dates is 90 days, and the earliest start date you can specify is two years prior to the current date, which is defined as 730 days (365 &#42; 2), not accounting for Leap Year.<br><br><a name=\"lastUDate\"></a>The last date for which traffic data exists is a value called <b>lastUpdatedDate</b>. eBay returns an error if you specify a date range greater than 90 days, or the start date is after the lastUpdatedDate. If the specified end date is beyond the lastUpdatedDate, eBay returns data up to the lastUpdatedDate.<br><br><b>Required:</b> Always</li> <li><b>listing_ids</b> <br>This filter limits the results to only the supplied list of <b>listingId</b> values. <br><br><span class=\"tablenote\"><b>Note:</b> If you specify <code>dimension=LISTING</code> without specifying any listing_ids in this parameter, the traffic report returned in the response contains a maximum of 200 listings.</span><br>You can specify to 200 different <b>listingId</b> values. Enclose the list of IDs with curly braces (\"<code>{ }</code>\"), and separate multiple values with a pipe character (\"<code>|</code>\").  <br><br>This filter only returns data for listings that have been either active or sold in last 90 days, and any unsold listings in the last 30 days. All listings must be the seller's and they  must be listed on the marketplace specified by the <b>marketplace_ids</b> filter argument.</li> <li><b>marketplace_ids</b> <br>This filter limits the report to seller data related to only the specified marketplace ID (currently the filter allows only a single marketplace ID). Enclose the marketplace ID in curly braces (\"<code>{ }</code>\").  <br><br><b>Valid values:</b> <ul class=\"compact\"><li><code>EBAY_AU</code></li> <li><code>EBAY_DE</code></li><li><code>EBAY_ES</code></li><li><code>EBAY_FR</code></li> <li><code>EBAY_GB</code></li> <li><code>EBAY_IT</code></li><li><code>EBAY_US</code></li> <li><code>EBAY_MOTORS_US</code></li></ul> <br><b>Required if</b> you set the <b>dimension</b> parameter to <code>DAY</code>.</li></ul> <br><b>Example filter parameter</b> <br>The following example shows how to configure the <b>filter</b> parameter with the <b>marketplace_ids</b> and <b>date_range</b> filters: <p><code>filter=marketplace_ids:{EBAY_US},date_range:[20170601..20170828]</code><br><br>Encoding this portion of the query parameter sample yields: <p><code>filter=marketplace_ids:%7BEBAY_US%7D,date_range:%5B20230601..20230828%5D</code> </p><br>See <a href=\" /api-docs/sell/analytics/resources/traffic_report/methods/getTrafficReport#h2-samples\">samples</a> for additional examples.<!-- **Filter results based on the specified filter parameters- window_days (WindowDaysEnum), date_range, marketplace_id (MarketplaceIdEnum - Only EBAY_US, EBAY_MOTORS_US, EBAY_GB, EBAY_AU, EBAY_DE are supported), listing_ids, traffic_source (Takes a list. Supported values: ORGANIC, PROMOTED_LISTINGS). Valid filters come from QueryParamEnum --> For implementation help, refer to eBay API documentation at https://developer.ebay.com/api-docs/sell/analytics/types/csb:FilterField
        :param str metric: <a name=\"metrics\"></a>This query parameter specifies the metrics you want covered in the report. <br><p><span class=\"tablenote\"><b>Note: </b> Unlike names for parameters and enumerated values, metric values are not case sensitive.</span></p><b>Valid values:</b><ul>    <li><a href=\"/api-docs/sell/static/performance/traffic-report.html#click_through_rate\" target=\"_blank\">CLICK_THROUGH_RATE</a></li>    <li><a href=\"/api-docs/sell/static/performance/traffic-report.html#listing_impression_search_results_page\" target=\"_blank\">LISTING_IMPRESSION_SEARCH_RESULTS_PAGE</a> </li>    <li><a href=\"/api-docs/sell/static/performance/traffic-report.html#listing_impression_store\" target=\"_blank\">LISTING_IMPRESSION_STORE</a></li>    <li><a href=\"/api-docs/sell/static/performance/traffic-report.html#listing_impression_total\" target=\"_blank\">LISTING_IMPRESSION_TOTAL</a></li>    <li><a href=\"/api-docs/sell/static/performance/traffic-report.html#listing_views_source_direct\" target=\"_blank\">LISTING_VIEWS_SOURCE_DIRECT</a></li>    <li><a href=\"/api-docs/sell/static/performance/traffic-report.html#listing_views_source_off_ebay\" target=\"_blank\">LISTING_VIEWS_SOURCE_OFF_EBAY</a></li>    <li><a href=\"/api-docs/sell/static/performance/traffic-report.html#listing_views_source_other_ebay\" target=\"_blank\">LISTING_VIEWS_SOURCE_OTHER_EBAY</a></li>    <li><a href=\"/api-docs/sell/static/performance/traffic-report.html#listing_views_source_search_results_page\" target=\"_blank\">LISTING_VIEWS_SOURCE_SEARCH_RESULTS_PAGE</a></li>    <li><a href=\"/api-docs/sell/static/performance/traffic-report.html#listing_views_source_store\" target=\"_blank\">LISTING_VIEWS_SOURCE_STORE</a></li>    <li><a href=\"/api-docs/sell/static/performance/traffic-report.html#listing_views_total\" target=\"_blank\">LISTING_VIEWS_TOTAL</a></li>    <li><a href=\"/api-docs/sell/static/performance/traffic-report.html#sales_conversion_rate\" target=\"_blank\">SALES_CONVERSION_RATE</a></li>    <li><a href=\"/api-docs/sell/static/performance/traffic-report.html#total_impression_total\" target=\"_blank\">TOTAL_IMPRESSION_TOTAL</a></li>    <li><a href=\"/api-docs/sell/static/performance/traffic-report.html#transaction\" target=\"_blank\">TRANSACTION</a></li></ul>Specify a comma-separated list of the metrics to include them in the report. See <a href=\"/api-docs/sell/static/performance/traffic-report.html#metric-parameters\" target=\"_blank\">Using different metric parameters</a> for more information including detailed metric descriptions and localized names.<!-- Metric - Lets the user specify the list of fields that they would like to see in the report. Allowed values: CLICK_THROUGH_RATE, LISTING_IMPRESSION_SEARCH_RESULTS_PAGE, LISTING_IMPRESSION_STORE, LISTING_IMPRESSION_TOTAL, LISTING_VIEWS_SOURCE_DIRECT, LISTING_VIEWS_SOURCE_OFF_EBAY, LISTING_VIEWS_SOURCE_OTHER_EBAY, LISTING_VIEWS_SOURCE_SEARCH_RESULTS_PAGE, LISTING_VIEWS_SOURCE_STORE, LISTING_VIEWS_TOTAL, SALES_CONVERSION_RATE (DataMetricEnum), TOTAL_IMPRESSION_TOTAL, TRANSACTION -->
        :param str sort: This query parameter sorts the report on the specified metric.  <br><br>You can only specify a single metric in the sort parameter and the specified metric must be included in the configuration of the report's <a href=\"#metrics\">metric</a> parameter.  <br><br>Sorting is helpful when you want to review how a specific metric is performing, such as the CLICK_THROUGH_RATE.  <br><br>Most reports can be sorted in ascending or descending order. Precede the value of a descending-order request with a minus sign (\"<code>-</code>\"), for example: <code>sort=-CLICK_THROUGH_RATE</code>.<br /><br /><span class=\"tablenote\"><b>Note:</b> There are a couple of constraints on sorting the report by different metrics:<ul><li>Sorting on the <code>SALES_CONVERSION_RATE</code> metric is not supported</li><li>The <code>TRANSACTION</code> metric can only be sorted in the descending order (sorting in the ascending order is not supported).</li></ul></span> <!-- Sort order for a collection of resources: Specify the metric value to be sorted. Allowed values are from DataMetricEnum --> For implementation help, refer to eBay API documentation at https://developer.ebay.com/api-docs/sell/analytics/types/csb:SortField
        :return: Report
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['dimension', 'filter', 'metric', 'sort']  # 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_traffic_report" % key
                )
            params[key] = val
        del params['kwargs']

        collection_formats = {}

        path_params = {}

        query_params = []
        if 'dimension' in params:
            query_params.append(('dimension', params['dimension']))  # noqa: E501
        if 'filter' in params:
            query_params.append(('filter', params['filter']))  # noqa: E501
        if 'metric' in params:
            query_params.append(('metric', params['metric']))  # noqa: E501
        if 'sort' in params:
            query_params.append(('sort', params['sort']))  # 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(
            '/traffic_report', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='Report',  # 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)
