# coding: utf-8

"""
    The Selling Partner API for Amazon Seller Wallet Open Banking API

    The Selling Partner API for Seller Wallet (Seller Wallet API) provides financial information that is relevant to a seller's Seller Wallet account. You can obtain financial events, balances, and transfer schedules for Seller Wallet accounts. You can also schedule and initiate transactions.

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

    Do not edit the class manually.
    """

    api_models_module = "spapi.models.seller_wallet_2024_03_01"

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

    def create_transaction(self, dest_account_digital_signature, amount_digital_signature, body, **kwargs):  # noqa: E501
        """Create a transaction request from Amazon Seller Wallet account to another customer-provided account  # noqa: E501

        Create a transaction request from an Amazon Seller Wallet account to another customer-provided account.  # 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_transaction(dest_account_digital_signature, amount_digital_signature, body, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str dest_account_digital_signature: Digital signature for the destination bank account details. (required)
        :param str amount_digital_signature: Digital signature for the source currency transaction amount. (required)
        :param TransactionInitiationRequest body: The payload of the request (required)
        :return: Transaction
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.create_transaction_with_http_info(dest_account_digital_signature, amount_digital_signature, body, **kwargs)  # noqa: E501
        else:
            (data) = self.create_transaction_with_http_info(dest_account_digital_signature, amount_digital_signature, body, **kwargs)  # noqa: E501
            return data

    def create_transaction_with_http_info(self, dest_account_digital_signature, amount_digital_signature, body, **kwargs):  # noqa: E501
        """Create a transaction request from Amazon Seller Wallet account to another customer-provided account  # noqa: E501

        Create a transaction request from an Amazon Seller Wallet account to another customer-provided account.  # 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_transaction_with_http_info(dest_account_digital_signature, amount_digital_signature, body, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str dest_account_digital_signature: Digital signature for the destination bank account details. (required)
        :param str amount_digital_signature: Digital signature for the source currency transaction amount. (required)
        :param TransactionInitiationRequest body: The payload of the request (required)
        :return: Transaction
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        collection_formats = {}

        path_params = {}

        query_params = []

        header_params = {}
        if 'dest_account_digital_signature' in params:
            header_params['destAccountDigitalSignature'] = params['dest_account_digital_signature']  # noqa: E501
        if 'amount_digital_signature' in params:
            header_params['amountDigitalSignature'] = params['amount_digital_signature']  # noqa: E501

        form_params = []
        local_var_files = {}

        body_params = None
        if 'body' in params:
            body_params = params['body']
        # 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(
            '/finances/transfers/wallet/2024-03-01/transactions', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='Transaction',  # 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_transaction(self, transaction_id, **kwargs):  # noqa: E501
        """Find particular Amazon Seller Wallet account transaction by Amazon transaction identifier  # noqa: E501

        Find a transaction by the Amazon transaction identifier.  # 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_transaction(transaction_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str transaction_id: The ID of the Amazon Seller Wallet transaction. (required)
        :return: Transaction
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.get_transaction_with_http_info(transaction_id, **kwargs)  # noqa: E501
        else:
            (data) = self.get_transaction_with_http_info(transaction_id, **kwargs)  # noqa: E501
            return data

    def get_transaction_with_http_info(self, transaction_id, **kwargs):  # noqa: E501
        """Find particular Amazon Seller Wallet account transaction by Amazon transaction identifier  # noqa: E501

        Find a transaction by the Amazon transaction identifier.  # 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_transaction_with_http_info(transaction_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str transaction_id: The ID of the Amazon Seller Wallet transaction. (required)
        :return: Transaction
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        collection_formats = {}

        path_params = {}
        if 'transaction_id' in params:
            path_params['transactionId'] = params['transaction_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(
            '/finances/transfers/wallet/2024-03-01/transactions/{transactionId}', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='Transaction',  # 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 list_account_transactions(self, account_id, **kwargs):  # noqa: E501
        """The API will return all the transactions for a given Amazon Seller Wallet account sorted by the transaction request date  # noqa: E501

        Retrieve a list of transactions for a given Amazon Seller Wallet bank account.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.list_account_transactions(account_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str account_id: The ID of the Amazon Seller Wallet account. (required)
        :param str next_page_token: A token that you use to retrieve the next page of results. The response includes `nextPageToken` when the number of results exceeds 100. To get the next page of results, call the operation with this token and include the same arguments as the call that produced the token. To get a complete list, call this operation until `nextPageToken` is null. Note that this operation can return empty pages.
        :return: TransactionListing
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.list_account_transactions_with_http_info(account_id, **kwargs)  # noqa: E501
        else:
            (data) = self.list_account_transactions_with_http_info(account_id, **kwargs)  # noqa: E501
            return data

    def list_account_transactions_with_http_info(self, account_id, **kwargs):  # noqa: E501
        """The API will return all the transactions for a given Amazon Seller Wallet account sorted by the transaction request date  # noqa: E501

        Retrieve a list of transactions for a given Amazon Seller Wallet bank account.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.list_account_transactions_with_http_info(account_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str account_id: The ID of the Amazon Seller Wallet account. (required)
        :param str next_page_token: A token that you use to retrieve the next page of results. The response includes `nextPageToken` when the number of results exceeds 100. To get the next page of results, call the operation with this token and include the same arguments as the call that produced the token. To get a complete list, call this operation until `nextPageToken` is null. Note that this operation can return empty pages.
        :return: TransactionListing
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        collection_formats = {}

        path_params = {}

        query_params = []
        if 'account_id' in params:
            query_params.append(('accountId', params['account_id']))  # noqa: E501
        if 'next_page_token' in params:
            query_params.append(('nextPageToken', params['next_page_token']))  # 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(
            '/finances/transfers/wallet/2024-03-01/transactions', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='TransactionListing',  # 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)
