# coding: utf-8

"""
    Rate Table API

    This API allows sellers to retrieve and manage their custom shipping rate tables. In addition, this API also provides sellers in mainland China methods to configure split-payouts between two separate payment instruments.  # noqa: E501

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


class RateTableApi(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_rate_table(self, rate_table_id, **kwargs):  # noqa: E501
        """get_rate_table  # noqa: E501

        This method retrieves an existing rate table identified by the <b>rate_table_id</b> path parameter.<br><br><b>getRateTable</b> currently supports the retrieval of rate tables for the following eBay marketplace IDs:<ul><li><code>EBAY_AU</code></li><li><code>EBAY_CA</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></ul> A successful call returns detailed information for the specified shipping rate table.  # 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_rate_table(rate_table_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str rate_table_id: This path parameter is the unique identifier for the shipping rate table to retrieve.<br/><br/> Use the <a href=\"/api-docs/sell/account/resources/rate_table/methods/getRateTables\" target=\"_blank\">getRateTables</a> method of the <a href=\"/api-docs/sell/account/static/overview.html \" target=\"_blank\">Account API v1</a> to retrieve rate table IDs. (required)
        :return: RateTableDetails
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.get_rate_table_with_http_info(rate_table_id, **kwargs)  # noqa: E501
        else:
            (data) = self.get_rate_table_with_http_info(rate_table_id, **kwargs)  # noqa: E501
            return data

    def get_rate_table_with_http_info(self, rate_table_id, **kwargs):  # noqa: E501
        """get_rate_table  # noqa: E501

        This method retrieves an existing rate table identified by the <b>rate_table_id</b> path parameter.<br><br><b>getRateTable</b> currently supports the retrieval of rate tables for the following eBay marketplace IDs:<ul><li><code>EBAY_AU</code></li><li><code>EBAY_CA</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></ul> A successful call returns detailed information for the specified shipping rate table.  # 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_rate_table_with_http_info(rate_table_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str rate_table_id: This path parameter is the unique identifier for the shipping rate table to retrieve.<br/><br/> Use the <a href=\"/api-docs/sell/account/resources/rate_table/methods/getRateTables\" target=\"_blank\">getRateTables</a> method of the <a href=\"/api-docs/sell/account/static/overview.html \" target=\"_blank\">Account API v1</a> to retrieve rate table IDs. (required)
        :return: RateTableDetails
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        collection_formats = {}

        path_params = {}
        if 'rate_table_id' in params:
            path_params['rate_table_id'] = params['rate_table_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(
            '/rate_table/{rate_table_id}', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='RateTableDetails',  # 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 update_shipping_cost(self, content_type, rate_table_id, **kwargs):  # noqa: E501
        """update_shipping_cost  # noqa: E501

        This method allows sellers to update <b>shippingCost</b> and/or <b>additionalCost</b> information for an existing shipping rate table identified by the <b>rate_table_id</b> path parameter.<br><br>A successful call returns an HTTP status code of <b>204 No Content</b>.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.update_shipping_cost(content_type, rate_table_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str content_type: This header indicates the format of the request body provided by the client. It's value should be set to <b>application/json</b>. <br><br> For more information, refer to <a href=\"/api-docs/static/rest-request-components.html#HTTP\" target=\"_blank \">HTTP request headers</a>. (required)
        :param str rate_table_id: This path parameter is the unique identifier for the shipping rate table for which shipping costs will be updated.<br/><br/> Use the <a href=\"/api-docs/sell/account/resources/rate_table/methods/getRateTables\" target=\"_blank\">getRateTables</a> method of the <a href=\"/api-docs/sell/account/static/overview.html \" target=\"_blank\">Account API v1</a> to retrieve rate table IDs. (required)
        :param RateTableUpdate body: Request to update the shipping costs for the identified shipping rate table.
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.update_shipping_cost_with_http_info(content_type, rate_table_id, **kwargs)  # noqa: E501
        else:
            (data) = self.update_shipping_cost_with_http_info(content_type, rate_table_id, **kwargs)  # noqa: E501
            return data

    def update_shipping_cost_with_http_info(self, content_type, rate_table_id, **kwargs):  # noqa: E501
        """update_shipping_cost  # noqa: E501

        This method allows sellers to update <b>shippingCost</b> and/or <b>additionalCost</b> information for an existing shipping rate table identified by the <b>rate_table_id</b> path parameter.<br><br>A successful call returns an HTTP status code of <b>204 No Content</b>.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.update_shipping_cost_with_http_info(content_type, rate_table_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str content_type: This header indicates the format of the request body provided by the client. It's value should be set to <b>application/json</b>. <br><br> For more information, refer to <a href=\"/api-docs/static/rest-request-components.html#HTTP\" target=\"_blank \">HTTP request headers</a>. (required)
        :param str rate_table_id: This path parameter is the unique identifier for the shipping rate table for which shipping costs will be updated.<br/><br/> Use the <a href=\"/api-docs/sell/account/resources/rate_table/methods/getRateTables\" target=\"_blank\">getRateTables</a> method of the <a href=\"/api-docs/sell/account/static/overview.html \" target=\"_blank\">Account API v1</a> to retrieve rate table IDs. (required)
        :param RateTableUpdate body: Request to update the shipping costs for the identified shipping rate table.
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        collection_formats = {}

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

        query_params = []

        header_params = {}
        if 'content_type' in params:
            header_params['Content-Type'] = params['content_type']  # noqa: E501

        form_params = []
        local_var_files = {}

        body_params = None
        if 'body' in params:
            body_params = params['body']
        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.select_header_content_type(  # noqa: E501
            ['application/json'])  # noqa: E501

        # Authentication setting
        auth_settings = ['api_auth']  # noqa: E501

        return self.api_client.call_api(
            '/rate_table/{rate_table_id}/update_shipping_cost', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type=None,  # 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)
