o
    tBh                     @   sD   d dl mZ d dlmZ d dlmZ d dlmZ G dd deZdS )    )	APIHelper)ApiResponse)BaseApi)OAuth2c                       sB   e Zd ZdZd fdd	Z			dddZdd Zd	d
 Z  ZS )BankAccountsApiz3A Controller to access Endpoints in the square API.Nc                    s   t t| || d S N)superr   __init__)selfconfig	call_back	__class__ s/var/www/html/riverr-enterprise-integrations-main/venv/lib/python3.10/site-packages/square/api/bank_accounts_api.pyr	      s   zBankAccountsApi.__init__c                 C   s   d}| j  }||7 }|||d}t||}t|}ddi}| j jj||d}	t| j |	 | 	|	}
t
|
j}t|tu rG|d}nd}t|
||d}|S )	a  Does a GET request to /v2/bank-accounts.

        Returns a list of [BankAccount]($m/BankAccount) objects linked to a
        Square account.

        Args:
            cursor (string, optional): The pagination cursor returned by a
                previous call to this endpoint. Use it in the next
                `ListBankAccounts` request to retrieve the next set  of
                results.  See the
                [Pagination](https://developer.squareup.com/docs/working-with-a
                pis/pagination) guide for more information.
            limit (int, optional): Upper limit on the number of bank accounts
                to return in the response.  Currently, 1000 is the largest
                supported limit. You can specify a limit  of up to 1000 bank
                accounts. This is also the default limit.
            location_id (string, optional): Location ID. You can specify this
                optional filter  to retrieve only the linked bank accounts
                belonging to a specific location.

        Returns:
            ApiResponse: An object with the response value as well as other
                useful information such as status codes and headers. Success

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        z/v2/bank-accounts)cursorlimitlocation_idacceptapplication/jsonheaderserrorsNbodyr   )r   get_base_urir    append_url_with_query_parameters	clean_urlhttp_clientgetr   applyexecute_requestjson_deserializetexttypedictr   )r
   r   r   r   	_url_path_query_builder_query_parameters
_query_url_headers_request	_responsedecoded_errors_resultr   r   r   list_bank_accounts   s.   %


z"BankAccountsApi.list_bank_accountsc                 C      d}t |d|ddi}| j }||7 }t |}ddi}| jjj||d}t| j| | 	|}t 
|j}t|tu rF|d}	nd	}	t|||	d
}
|
S )a  Does a GET request to /v2/bank-accounts/by-v1-id/{v1_bank_account_id}.

        Returns details of a [BankAccount]($m/BankAccount) identified by V1
        bank account ID.

        Args:
            v1_bank_account_id (string): Connect V1 ID of the desired
                `BankAccount`. For more information, see  [Retrieve a bank
                account by using an ID issued by V1 Bank Accounts
                API](https://developer.squareup.com/docs/bank-accounts-api#retr
                ieve-a-bank-account-by-using-an-id-issued-by-v1-bank-accounts-a
                pi).

        Returns:
            ApiResponse: An object with the response value as well as other
                useful information such as status codes and headers. Success

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        z//v2/bank-accounts/by-v1-id/{v1_bank_account_id}v1_bank_account_idTvalueencoder   r   r   r   Nr   r   #append_url_with_template_parametersr   r   r   r   r   r   r    r!   r"   r#   r$   r%   r   )r
   r2   r&   r'   r)   r*   r+   r,   r-   r.   r/   r   r   r   get_bank_account_by_v1_idU   s$   



z)BankAccountsApi.get_bank_account_by_v1_idc                 C   r1   )a  Does a GET request to /v2/bank-accounts/{bank_account_id}.

        Returns details of a [BankAccount]($m/BankAccount)
        linked to a Square account.

        Args:
            bank_account_id (string): Square-issued ID of the desired
                `BankAccount`.

        Returns:
            ApiResponse: An object with the response value as well as other
                useful information such as status codes and headers. Success

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        z#/v2/bank-accounts/{bank_account_id}bank_account_idTr3   r   r   r   r   Nr   r6   )r
   r9   r&   r'   r)   r*   r+   r,   r-   r.   r/   r   r   r   get_bank_account   s$   



z BankAccountsApi.get_bank_accountr   )NNN)	__name__
__module____qualname____doc__r	   r0   r8   r:   __classcell__r   r   r   r   r   	   s    
E6r   N)	square.api_helperr   square.http.api_responser   square.api.base_apir   square.http.auth.o_auth_2r   r   r   r   r   r   <module>   s
   