# coding: utf-8

"""
    Selling Partner API for Supply Sources

    Manage configurations and capabilities of seller supply sources.

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

    Do not edit the class manually.
    """

    api_models_module = "spapi.models.supply_sources_v2020_07_01"

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

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

        Archive a supply source, making it inactive. Cannot be undone.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.archive_supply_source(supply_source_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str supply_source_id: The unique identifier of a supply source. (required)
        :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.archive_supply_source_with_http_info(supply_source_id, **kwargs)  # noqa: E501
        else:
            (data) = self.archive_supply_source_with_http_info(supply_source_id, **kwargs)  # noqa: E501
            return data

    def archive_supply_source_with_http_info(self, supply_source_id, **kwargs):  # noqa: E501
        """archive_supply_source  # noqa: E501

        Archive a supply source, making it inactive. Cannot be undone.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.archive_supply_source_with_http_info(supply_source_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str supply_source_id: The unique identifier of a supply source. (required)
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['supply_source_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 archive_supply_source" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'supply_source_id' is set
        if self.api_client.client_side_validation and ('supply_source_id' not in params or
                                                       params['supply_source_id'] is None):  # noqa: E501
            raise ValueError("Missing the required parameter `supply_source_id` when calling `archive_supply_source`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'supply_source_id' in params:
            path_params['supplySourceId'] = params['supply_source_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 = []  # noqa: E501

        return self.api_client.call_api(
            '/supplySources/2020-07-01/supplySources/{supplySourceId}', 'DELETE',
            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, api_models_module=self.api_models_module)

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

        Create a new supply source.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.create_supply_source(payload, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param CreateSupplySourceRequest payload: A request to create a supply source. (required)
        :return: CreateSupplySourceResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.create_supply_source_with_http_info(payload, **kwargs)  # noqa: E501
        else:
            (data) = self.create_supply_source_with_http_info(payload, **kwargs)  # noqa: E501
            return data

    def create_supply_source_with_http_info(self, payload, **kwargs):  # noqa: E501
        """create_supply_source  # noqa: E501

        Create a new supply source.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.create_supply_source_with_http_info(payload, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param CreateSupplySourceRequest payload: A request to create a supply source. (required)
        :return: CreateSupplySourceResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['payload']  # 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 create_supply_source" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'payload' is set
        if self.api_client.client_side_validation and ('payload' not in params or
                                                       params['payload'] is None):  # noqa: E501
            raise ValueError("Missing the required parameter `payload` when calling `create_supply_source`")  # noqa: E501

        collection_formats = {}

        path_params = {}

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'payload' in params:
            body_params = params['payload']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json'])  # noqa: E501

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

        return self.api_client.call_api(
            '/supplySources/2020-07-01/supplySources', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='CreateSupplySourceResponse',  # 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)

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

        Retrieve a supply source.  # 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_supply_source(supply_source_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str supply_source_id: The unique identifier of a supply source. (required)
        :return: SupplySource
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.get_supply_source_with_http_info(supply_source_id, **kwargs)  # noqa: E501
        else:
            (data) = self.get_supply_source_with_http_info(supply_source_id, **kwargs)  # noqa: E501
            return data

    def get_supply_source_with_http_info(self, supply_source_id, **kwargs):  # noqa: E501
        """get_supply_source  # noqa: E501

        Retrieve a supply source.  # 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_supply_source_with_http_info(supply_source_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str supply_source_id: The unique identifier of a supply source. (required)
        :return: SupplySource
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['supply_source_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_supply_source" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'supply_source_id' is set
        if self.api_client.client_side_validation and ('supply_source_id' not in params or
                                                       params['supply_source_id'] is None):  # noqa: E501
            raise ValueError("Missing the required parameter `supply_source_id` when calling `get_supply_source`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'supply_source_id' in params:
            path_params['supplySourceId'] = params['supply_source_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 = []  # noqa: E501

        return self.api_client.call_api(
            '/supplySources/2020-07-01/supplySources/{supplySourceId}', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='SupplySource',  # 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)

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

        The path to retrieve paginated supply sources.  # 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_supply_sources(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str next_page_token: The pagination token to retrieve a specific page of results.
        :param float page_size: The number of supply sources to return per paginated request.
        :return: GetSupplySourcesResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.get_supply_sources_with_http_info(**kwargs)  # noqa: E501
        else:
            (data) = self.get_supply_sources_with_http_info(**kwargs)  # noqa: E501
            return data

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

        The path to retrieve paginated supply sources.  # 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_supply_sources_with_http_info(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str next_page_token: The pagination token to retrieve a specific page of results.
        :param float page_size: The number of supply sources to return per paginated request.
        :return: GetSupplySourcesResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['next_page_token', 'page_size']  # 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_supply_sources" % key
                )
            params[key] = val
        del params['kwargs']

        collection_formats = {}

        path_params = {}

        query_params = []
        if 'next_page_token' in params:
            query_params.append(('nextPageToken', params['next_page_token']))  # noqa: E501
        if 'page_size' in params:
            query_params.append(('pageSize', params['page_size']))  # 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(
            '/supplySources/2020-07-01/supplySources', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='GetSupplySourcesResponse',  # 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)

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

        Update the configuration and capabilities of a supply source.  # 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_supply_source(supply_source_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str supply_source_id: The unique identitier of a supply source. (required)
        :param UpdateSupplySourceRequest payload:
        :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_supply_source_with_http_info(supply_source_id, **kwargs)  # noqa: E501
        else:
            (data) = self.update_supply_source_with_http_info(supply_source_id, **kwargs)  # noqa: E501
            return data

    def update_supply_source_with_http_info(self, supply_source_id, **kwargs):  # noqa: E501
        """update_supply_source  # noqa: E501

        Update the configuration and capabilities of a supply source.  # 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_supply_source_with_http_info(supply_source_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str supply_source_id: The unique identitier of a supply source. (required)
        :param UpdateSupplySourceRequest payload:
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['supply_source_id', 'payload']  # 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_supply_source" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'supply_source_id' is set
        if self.api_client.client_side_validation and ('supply_source_id' not in params or
                                                       params['supply_source_id'] is None):  # noqa: E501
            raise ValueError("Missing the required parameter `supply_source_id` when calling `update_supply_source`")  # noqa: E501

        collection_formats = {}

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

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'payload' in params:
            body_params = params['payload']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json'])  # noqa: E501

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

        return self.api_client.call_api(
            '/supplySources/2020-07-01/supplySources/{supplySourceId}', 'PUT',
            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, api_models_module=self.api_models_module)

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

        Update the status of a supply source.  # 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_supply_source_status(supply_source_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str supply_source_id: The unique identifier of a supply source. (required)
        :param UpdateSupplySourceStatusRequest payload:
        :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_supply_source_status_with_http_info(supply_source_id, **kwargs)  # noqa: E501
        else:
            (data) = self.update_supply_source_status_with_http_info(supply_source_id, **kwargs)  # noqa: E501
            return data

    def update_supply_source_status_with_http_info(self, supply_source_id, **kwargs):  # noqa: E501
        """update_supply_source_status  # noqa: E501

        Update the status of a supply source.  # 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_supply_source_status_with_http_info(supply_source_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str supply_source_id: The unique identifier of a supply source. (required)
        :param UpdateSupplySourceStatusRequest payload:
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['supply_source_id', 'payload']  # 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_supply_source_status" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'supply_source_id' is set
        if self.api_client.client_side_validation and ('supply_source_id' not in params or
                                                       params['supply_source_id'] is None):  # noqa: E501
            raise ValueError("Missing the required parameter `supply_source_id` when calling `update_supply_source_status`")  # noqa: E501

        collection_formats = {}

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

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'payload' in params:
            body_params = params['payload']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json'])  # noqa: E501

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

        return self.api_client.call_api(
            '/supplySources/2020-07-01/supplySources/{supplySourceId}/status', 'PUT',
            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, api_models_module=self.api_models_module)
