# coding: utf-8

"""
    currencyapi

    The currency APIs help you retrieve exchange rates and convert prices between currencies easily.  # noqa: E501

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


class CurrencyExchangeApi(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 currency_exchange_convert_currency(self, source, destination, source_price, **kwargs):  # noqa: E501
        """Converts a price from the source currency into the destination currency  # noqa: E501

        Automatically converts the price in the source currency into the destination currency using the latest available currency exchange rate data.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.currency_exchange_convert_currency(source, destination, source_price, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str source: Source currency three-digit code (ISO 4217), e.g. USD, EUR, etc. (required)
        :param str destination: Destination currency three-digit code (ISO 4217), e.g. USD, EUR, etc. (required)
        :param float source_price: Input price, such as 19.99 in source currency (required)
        :return: ConvertedCurrencyResult
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.currency_exchange_convert_currency_with_http_info(source, destination, source_price, **kwargs)  # noqa: E501
        else:
            (data) = self.currency_exchange_convert_currency_with_http_info(source, destination, source_price, **kwargs)  # noqa: E501
            return data

    def currency_exchange_convert_currency_with_http_info(self, source, destination, source_price, **kwargs):  # noqa: E501
        """Converts a price from the source currency into the destination currency  # noqa: E501

        Automatically converts the price in the source currency into the destination currency using the latest available currency exchange rate data.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.currency_exchange_convert_currency_with_http_info(source, destination, source_price, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str source: Source currency three-digit code (ISO 4217), e.g. USD, EUR, etc. (required)
        :param str destination: Destination currency three-digit code (ISO 4217), e.g. USD, EUR, etc. (required)
        :param float source_price: Input price, such as 19.99 in source currency (required)
        :return: ConvertedCurrencyResult
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        collection_formats = {}

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

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

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

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.select_header_content_type(  # noqa: E501
            ['application/json', 'text/json'])  # noqa: E501

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

        return self.api_client.call_api(
            '/currency/exchange-rates/convert/{source}/to/{destination}', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='ConvertedCurrencyResult',  # 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 currency_exchange_get_available_currencies(self, **kwargs):  # noqa: E501
        """Get a list of available currencies and corresponding countries  # noqa: E501

        Enumerates available currencies and the countries that correspond to these currencies.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.currency_exchange_get_available_currencies(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :return: AvailableCurrencyResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.currency_exchange_get_available_currencies_with_http_info(**kwargs)  # noqa: E501
        else:
            (data) = self.currency_exchange_get_available_currencies_with_http_info(**kwargs)  # noqa: E501
            return data

    def currency_exchange_get_available_currencies_with_http_info(self, **kwargs):  # noqa: E501
        """Get a list of available currencies and corresponding countries  # noqa: E501

        Enumerates available currencies and the countries that correspond to these currencies.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.currency_exchange_get_available_currencies_with_http_info(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :return: AvailableCurrencyResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        collection_formats = {}

        path_params = {}

        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', 'text/json', 'application/xml', 'text/xml'])  # noqa: E501

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

        return self.api_client.call_api(
            '/currency/exchange-rates/list-available', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='AvailableCurrencyResponse',  # 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 currency_exchange_get_exchange_rate(self, source, destination, **kwargs):  # noqa: E501
        """Gets the exchange rate from the source currency into the destination currency  # noqa: E501

        Automatically gets the exchange rate from the source currency into the destination currency using the latest available currency exchange rate data.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.currency_exchange_get_exchange_rate(source, destination, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str source: Source currency three-digit code (ISO 4217), e.g. USD, EUR, etc. (required)
        :param str destination: Destination currency three-digit code (ISO 4217), e.g. USD, EUR, etc. (required)
        :return: ExchangeRateResult
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.currency_exchange_get_exchange_rate_with_http_info(source, destination, **kwargs)  # noqa: E501
        else:
            (data) = self.currency_exchange_get_exchange_rate_with_http_info(source, destination, **kwargs)  # noqa: E501
            return data

    def currency_exchange_get_exchange_rate_with_http_info(self, source, destination, **kwargs):  # noqa: E501
        """Gets the exchange rate from the source currency into the destination currency  # noqa: E501

        Automatically gets the exchange rate from the source currency into the destination currency using the latest available currency exchange rate data.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.currency_exchange_get_exchange_rate_with_http_info(source, destination, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str source: Source currency three-digit code (ISO 4217), e.g. USD, EUR, etc. (required)
        :param str destination: Destination currency three-digit code (ISO 4217), e.g. USD, EUR, etc. (required)
        :return: ExchangeRateResult
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        collection_formats = {}

        path_params = {}
        if 'source' in params:
            path_params['source'] = params['source']  # noqa: E501
        if 'destination' in params:
            path_params['destination'] = params['destination']  # 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', 'text/json', 'application/xml', 'text/xml'])  # noqa: E501

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

        return self.api_client.call_api(
            '/currency/exchange-rates/get/{source}/to/{destination}', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='ExchangeRateResult',  # 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)
