# coding: utf-8

"""
    CryptoAPIs

    Crypto APIs is a complex and innovative infrastructure layer that radically simplifies the development of any Blockchain and Crypto related applications. Organized around REST, Crypto APIs can assist both novice Bitcoin/Ethereum enthusiasts and crypto experts with the development of their blockchain applications. Crypto APIs provides unified endpoints and data, raw data, automatic tokens and coins forwardings, callback functionalities, and much more.  # noqa: E501

    The version of the OpenAPI document: 2021-03-20
    Contact: developers@cryptoapis.io
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""


import re  # noqa: F401
import io
import warnings

from pydantic import validate_arguments, ValidationError
from typing_extensions import Annotated

from pydantic import Field, StrictStr

from typing import Optional

from cryptoapis.models.create_new_master_wallet_r import CreateNewMasterWalletR
from cryptoapis.models.create_new_master_wallet_rb import CreateNewMasterWalletRB
from cryptoapis.models.generate_deposit_address_r import GenerateDepositAddressR
from cryptoapis.models.generate_deposit_address_rb import GenerateDepositAddressRB

from cryptoapis.api_client import ApiClient
from cryptoapis.api_response import ApiResponse
from cryptoapis.exceptions import (  # noqa: F401
    ApiTypeError,
    ApiValueError
)


class GeneratingApi(object):
    """NOTE: This class is auto generated by OpenAPI Generator
    Ref: https://openapi-generator.tech

    Do not edit the class manually.
    """

    def __init__(self, api_client=None):
        if api_client is None:
            api_client = ApiClient.get_default()
        self.api_client = api_client

    @validate_arguments
    def create_new_master_wallet(self, context : Annotated[Optional[StrictStr], Field(description="In batch situations the user can use the context to correlate responses with requests. This property is present regardless of whether the response was successful or returned as an error. `context` is specified by the user.")] = None, create_new_master_wallet_rb : Optional[CreateNewMasterWalletRB] = None, **kwargs) -> CreateNewMasterWalletR:  # noqa: E501
        """Create New Master Wallet  # noqa: E501

        Through this endpoint users can easily create a new Master Wallet through the API. The user provides the desired Wallet name and in return the response includes the `walletId`. That new Wallet can be additionally also backed up through the Crypto APIs Dashboard.  # 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_new_master_wallet(context, create_new_master_wallet_rb, async_req=True)
        >>> result = thread.get()

        :param context: In batch situations the user can use the context to correlate responses with requests. This property is present regardless of whether the response was successful or returned as an error. `context` is specified by the user.
        :type context: str
        :param create_new_master_wallet_rb:
        :type create_new_master_wallet_rb: CreateNewMasterWalletRB
        :param async_req: Whether to execute the request asynchronously.
        :type async_req: bool, optional
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: CreateNewMasterWalletR
        """
        kwargs['_return_http_data_only'] = True
        if '_preload_content' in kwargs:
            raise ValueError("Error! Please call the create_new_master_wallet_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data")
        return self.create_new_master_wallet_with_http_info(context, create_new_master_wallet_rb, **kwargs)  # noqa: E501

    @validate_arguments
    def create_new_master_wallet_with_http_info(self, context : Annotated[Optional[StrictStr], Field(description="In batch situations the user can use the context to correlate responses with requests. This property is present regardless of whether the response was successful or returned as an error. `context` is specified by the user.")] = None, create_new_master_wallet_rb : Optional[CreateNewMasterWalletRB] = None, **kwargs) -> ApiResponse:  # noqa: E501
        """Create New Master Wallet  # noqa: E501

        Through this endpoint users can easily create a new Master Wallet through the API. The user provides the desired Wallet name and in return the response includes the `walletId`. That new Wallet can be additionally also backed up through the Crypto APIs Dashboard.  # 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_new_master_wallet_with_http_info(context, create_new_master_wallet_rb, async_req=True)
        >>> result = thread.get()

        :param context: In batch situations the user can use the context to correlate responses with requests. This property is present regardless of whether the response was successful or returned as an error. `context` is specified by the user.
        :type context: str
        :param create_new_master_wallet_rb:
        :type create_new_master_wallet_rb: CreateNewMasterWalletRB
        :param async_req: Whether to execute the request asynchronously.
        :type async_req: bool, optional
        :param _preload_content: if False, the ApiResponse.data will
                                 be set to none and raw_data will store the 
                                 HTTP response body without reading/decoding.
                                 Default is True.
        :type _preload_content: bool, optional
        :param _return_http_data_only: response data instead of ApiResponse
                                       object with status code, headers, etc
        :type _return_http_data_only: bool, optional
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the authentication
                              in the spec for a single request.
        :type _request_auth: dict, optional
        :type _content_type: string, optional: force content-type for the request
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: tuple(CreateNewMasterWalletR, status_code(int), headers(HTTPHeaderDict))
        """

        _params = locals()

        _all_params = [
            'context',
            'create_new_master_wallet_rb'
        ]
        _all_params.extend(
            [
                'async_req',
                '_return_http_data_only',
                '_preload_content',
                '_request_timeout',
                '_request_auth',
                '_content_type',
                '_headers'
            ]
        )

        # validate the arguments
        for _key, _val in _params['kwargs'].items():
            if _key not in _all_params:
                raise ApiTypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method create_new_master_wallet" % _key
                )
            _params[_key] = _val
        del _params['kwargs']

        _collection_formats = {}

        # process the path parameters
        _path_params = {}

        # process the query parameters
        _query_params = []
        if _params.get('context') is not None:  # noqa: E501
            _query_params.append(('context', _params['context']))

        # process the header parameters
        _header_params = dict(_params.get('_headers', {}))
        # process the form parameters
        _form_params = []
        _files = {}
        # process the body parameter
        _body_params = None
        if _params['create_new_master_wallet_rb'] is not None:
            _body_params = _params['create_new_master_wallet_rb']

        # set the HTTP header `Accept`
        _header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json'])  # noqa: E501

        # set the HTTP header `Content-Type`
        _content_types_list = _params.get('_content_type',
            self.api_client.select_header_content_type(
                ['application/json']))
        if _content_types_list:
                _header_params['Content-Type'] = _content_types_list

        # authentication setting
        _auth_settings = ['ApiKey']  # noqa: E501

        _response_types_map = {
            '201': "CreateNewMasterWalletR",
            '400': "CreateNewMasterWallet400Response",
            '401': "CreateNewMasterWallet401Response",
            '402': "ConvertBitcoinCashAddress402Response",
            '403': "CreateNewMasterWallet403Response",
            '409': "ConvertBitcoinCashAddress409Response",
            '415': "ConvertBitcoinCashAddress415Response",
            '422': "ConvertBitcoinCashAddress422Response",
            '429': "ConvertBitcoinCashAddress429Response",
            '500': "ConvertBitcoinCashAddress500Response",
        }

        return self.api_client.call_api(
            '/wallet-as-a-service/wallets/generate', 'POST',
            _path_params,
            _query_params,
            _header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            response_types_map=_response_types_map,
            auth_settings=_auth_settings,
            async_req=_params.get('async_req'),
            _return_http_data_only=_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=_params.get('_preload_content', True),
            _request_timeout=_params.get('_request_timeout'),
            collection_formats=_collection_formats,
            _request_auth=_params.get('_request_auth'))

    @validate_arguments
    def generate_deposit_address(self, blockchain : Annotated[StrictStr, Field(..., description="Represents the specific blockchain protocol name, e.g. Ethereum, Bitcoin, etc.")], network : Annotated[StrictStr, Field(..., description="Represents the name of the blockchain network used; blockchain networks are usually identical as technology and software, but they differ in data, e.g. - \"mainnet\" is the live network with actual data while networks like \"testnet\", \"goerli\" are test networks.")], wallet_id : Annotated[StrictStr, Field(..., description="Represents the unique ID of the specific Wallet.")], context : Annotated[Optional[StrictStr], Field(description="In batch situations the user can use the context to correlate responses with requests. This property is present regardless of whether the response was successful or returned as an error. `context` is specified by the user.")] = None, generate_deposit_address_rb : Optional[GenerateDepositAddressRB] = None, **kwargs) -> GenerateDepositAddressR:  # noqa: E501
        """Generate Deposit Address  # noqa: E501

        Through this endpoint customers can generate a new Receiving/Deposit Addresses into their Wallet.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True

        >>> thread = api.generate_deposit_address(blockchain, network, wallet_id, context, generate_deposit_address_rb, async_req=True)
        >>> result = thread.get()

        :param blockchain: Represents the specific blockchain protocol name, e.g. Ethereum, Bitcoin, etc. (required)
        :type blockchain: str
        :param network: Represents the name of the blockchain network used; blockchain networks are usually identical as technology and software, but they differ in data, e.g. - \"mainnet\" is the live network with actual data while networks like \"testnet\", \"goerli\" are test networks. (required)
        :type network: str
        :param wallet_id: Represents the unique ID of the specific Wallet. (required)
        :type wallet_id: str
        :param context: In batch situations the user can use the context to correlate responses with requests. This property is present regardless of whether the response was successful or returned as an error. `context` is specified by the user.
        :type context: str
        :param generate_deposit_address_rb:
        :type generate_deposit_address_rb: GenerateDepositAddressRB
        :param async_req: Whether to execute the request asynchronously.
        :type async_req: bool, optional
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: GenerateDepositAddressR
        """
        kwargs['_return_http_data_only'] = True
        if '_preload_content' in kwargs:
            raise ValueError("Error! Please call the generate_deposit_address_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data")
        return self.generate_deposit_address_with_http_info(blockchain, network, wallet_id, context, generate_deposit_address_rb, **kwargs)  # noqa: E501

    @validate_arguments
    def generate_deposit_address_with_http_info(self, blockchain : Annotated[StrictStr, Field(..., description="Represents the specific blockchain protocol name, e.g. Ethereum, Bitcoin, etc.")], network : Annotated[StrictStr, Field(..., description="Represents the name of the blockchain network used; blockchain networks are usually identical as technology and software, but they differ in data, e.g. - \"mainnet\" is the live network with actual data while networks like \"testnet\", \"goerli\" are test networks.")], wallet_id : Annotated[StrictStr, Field(..., description="Represents the unique ID of the specific Wallet.")], context : Annotated[Optional[StrictStr], Field(description="In batch situations the user can use the context to correlate responses with requests. This property is present regardless of whether the response was successful or returned as an error. `context` is specified by the user.")] = None, generate_deposit_address_rb : Optional[GenerateDepositAddressRB] = None, **kwargs) -> ApiResponse:  # noqa: E501
        """Generate Deposit Address  # noqa: E501

        Through this endpoint customers can generate a new Receiving/Deposit Addresses into their Wallet.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True

        >>> thread = api.generate_deposit_address_with_http_info(blockchain, network, wallet_id, context, generate_deposit_address_rb, async_req=True)
        >>> result = thread.get()

        :param blockchain: Represents the specific blockchain protocol name, e.g. Ethereum, Bitcoin, etc. (required)
        :type blockchain: str
        :param network: Represents the name of the blockchain network used; blockchain networks are usually identical as technology and software, but they differ in data, e.g. - \"mainnet\" is the live network with actual data while networks like \"testnet\", \"goerli\" are test networks. (required)
        :type network: str
        :param wallet_id: Represents the unique ID of the specific Wallet. (required)
        :type wallet_id: str
        :param context: In batch situations the user can use the context to correlate responses with requests. This property is present regardless of whether the response was successful or returned as an error. `context` is specified by the user.
        :type context: str
        :param generate_deposit_address_rb:
        :type generate_deposit_address_rb: GenerateDepositAddressRB
        :param async_req: Whether to execute the request asynchronously.
        :type async_req: bool, optional
        :param _preload_content: if False, the ApiResponse.data will
                                 be set to none and raw_data will store the 
                                 HTTP response body without reading/decoding.
                                 Default is True.
        :type _preload_content: bool, optional
        :param _return_http_data_only: response data instead of ApiResponse
                                       object with status code, headers, etc
        :type _return_http_data_only: bool, optional
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the authentication
                              in the spec for a single request.
        :type _request_auth: dict, optional
        :type _content_type: string, optional: force content-type for the request
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: tuple(GenerateDepositAddressR, status_code(int), headers(HTTPHeaderDict))
        """

        _params = locals()

        _all_params = [
            'blockchain',
            'network',
            'wallet_id',
            'context',
            'generate_deposit_address_rb'
        ]
        _all_params.extend(
            [
                'async_req',
                '_return_http_data_only',
                '_preload_content',
                '_request_timeout',
                '_request_auth',
                '_content_type',
                '_headers'
            ]
        )

        # validate the arguments
        for _key, _val in _params['kwargs'].items():
            if _key not in _all_params:
                raise ApiTypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method generate_deposit_address" % _key
                )
            _params[_key] = _val
        del _params['kwargs']

        _collection_formats = {}

        # process the path parameters
        _path_params = {}
        if _params['blockchain']:
            _path_params['blockchain'] = _params['blockchain']

        if _params['network']:
            _path_params['network'] = _params['network']

        if _params['wallet_id']:
            _path_params['walletId'] = _params['wallet_id']


        # process the query parameters
        _query_params = []
        if _params.get('context') is not None:  # noqa: E501
            _query_params.append(('context', _params['context']))

        # process the header parameters
        _header_params = dict(_params.get('_headers', {}))
        # process the form parameters
        _form_params = []
        _files = {}
        # process the body parameter
        _body_params = None
        if _params['generate_deposit_address_rb'] is not None:
            _body_params = _params['generate_deposit_address_rb']

        # set the HTTP header `Accept`
        _header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json'])  # noqa: E501

        # set the HTTP header `Content-Type`
        _content_types_list = _params.get('_content_type',
            self.api_client.select_header_content_type(
                ['application/json']))
        if _content_types_list:
                _header_params['Content-Type'] = _content_types_list

        # authentication setting
        _auth_settings = ['ApiKey']  # noqa: E501

        _response_types_map = {
            '201': "GenerateDepositAddressR",
            '400': "GenerateDepositAddress400Response",
            '401': "GenerateDepositAddress401Response",
            '402': "ConvertBitcoinCashAddress402Response",
            '403': "GenerateDepositAddress403Response",
            '404': "GetXRPRippleTransactionDetailsByTransactionID404Response",
            '409': "ConvertBitcoinCashAddress409Response",
            '415': "ConvertBitcoinCashAddress415Response",
            '422': "ConvertBitcoinCashAddress422Response",
            '429': "ConvertBitcoinCashAddress429Response",
            '500': "ConvertBitcoinCashAddress500Response",
        }

        return self.api_client.call_api(
            '/wallet-as-a-service/wallets/{walletId}/{blockchain}/{network}/addresses', 'POST',
            _path_params,
            _query_params,
            _header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            response_types_map=_response_types_map,
            auth_settings=_auth_settings,
            async_req=_params.get('async_req'),
            _return_http_data_only=_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=_params.get('_preload_content', True),
            _request_timeout=_params.get('_request_timeout'),
            collection_formats=_collection_formats,
            _request_auth=_params.get('_request_auth'))
