o
    tBh)                     @   sP   d dl mZ 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 )	    )
deprecated)	APIHelper)ApiResponse)BaseApi)OAuth2c                       sd   e Zd ZdZd fdd	Ze 				dddZe dd Ze d	d
 Ze dd Z	  Z
S )TransactionsApiz3A Controller to access Endpoints in the square API.Nc                    s   t t| || d S N)superr   __init__)selfconfig	call_back	__class__ r/var/www/html/riverr-enterprise-integrations-main/venv/lib/python3.10/site-packages/square/api/transactions_api.pyr
      s   zTransactionsApi.__init__c                 C   s   d}t |d|ddi}| j }||7 }||||d}t ||}t |}	ddi}
| jjj|	|
d}t	| j| | 
|}t |j}t|tu rS|d	}nd
}t|||d}|S )a  Does a GET request to /v2/locations/{location_id}/transactions.

        Lists transactions for a particular location.
        Transactions include payment information from sales and exchanges and
        refund
        information from returns and exchanges.
        Max results per
        [page](https://developer.squareup.com/docs/working-with-apis/pagination
        ): 50

        Args:
            location_id (string): The ID of the location to list transactions
                for.
            begin_time (string, optional): The beginning of the requested
                reporting period, in RFC 3339 format.  See [Date
                ranges](https://developer.squareup.com/docs/build-basics/workin
                g-with-dates) for details on date inclusivity/exclusivity. 
                Default value: The current time minus one year.
            end_time (string, optional): The end of the requested reporting
                period, in RFC 3339 format.  See [Date
                ranges](https://developer.squareup.com/docs/build-basics/workin
                g-with-dates) for details on date inclusivity/exclusivity. 
                Default value: The current time.
            sort_order (SortOrder, optional): The order in which results are
                listed in the response (`ASC` for oldest first, `DESC` for
                newest first).  Default value: `DESC`
            cursor (string, optional): A pagination cursor returned by a
                previous call to this endpoint. Provide this to retrieve the
                next set of results for your original query.  See [Paginating
                results](https://developer.squareup.com/docs/working-with-apis/
                pagination) for more information.

        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/locations/{location_id}/transactionslocation_idTvalueencode)
begin_timeend_time
sort_ordercursoracceptapplication/jsonheaderserrorsNbodyr   )r   #append_url_with_template_parametersr   get_base_uri append_url_with_query_parameters	clean_urlhttp_clientgetr   applyexecute_requestjson_deserializetexttypedictr   )r   r   r   r   r   r   	_url_path_query_builder_query_parameters
_query_url_headers_request	_responsedecoded_errors_resultr   r   r   list_transactions   s6   4



z!TransactionsApi.list_transactionsc                 C   s   d}t ||dd|ddd}| j }||7 }t |}ddi}| jjj||d}t| j| | 	|}t 
|j}	t|	tu rJ|	d}
nd	}
t||	|
d
}|S )a  Does a GET request to /v2/locations/{location_id}/transactions/{transaction_id}.

        Retrieves details for a single transaction.

        Args:
            location_id (string): The ID of the transaction's associated
                location.
            transaction_id (string): The ID of the transaction to retrieve.

        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.

        z9/v2/locations/{location_id}/transactions/{transaction_id}Tr   r   transaction_idr   r   r   r   Nr   )r   r!   r   r"   r$   r%   r&   r   r'   r(   r)   r*   r+   r,   r   r   r   r9   r-   r.   r0   r1   r2   r3   r4   r5   r6   r   r   r   retrieve_transactioni   s&   


z$TransactionsApi.retrieve_transactionc                 C      d}t ||dd|ddd}| j }||7 }t |}ddi}| jjj||d}t| j| | 	|}t 
|j}	t|	tu rJ|	d}
nd	}
t||	|
d
}|S )a  Does a POST request to /v2/locations/{location_id}/transactions/{transaction_id}/capture.

        Captures a transaction that was created with the
        [Charge]($e/Transactions/Charge)
        endpoint with a `delay_capture` value of `true`.
        See [Delayed capture
        transactions](https://developer.squareup.com/docs/payments/transactions
        /overview#delayed-capture)
        for more information.

        Args:
            location_id (string): TODO: type description here.
            transaction_id (string): TODO: type description here.

        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.

        zA/v2/locations/{location_id}/transactions/{transaction_id}/captureTr   r8   r   r   r   r   Nr   r   r!   r   r"   r$   r%   postr   r'   r(   r)   r*   r+   r,   r&   r   r:   r   r   r   capture_transaction   &   


z#TransactionsApi.capture_transactionc                 C   r<   )a  Does a POST request to /v2/locations/{location_id}/transactions/{transaction_id}/void.

        Cancels a transaction that was created with the
        [Charge]($e/Transactions/Charge)
        endpoint with a `delay_capture` value of `true`.
        See [Delayed capture
        transactions](https://developer.squareup.com/docs/payments/transactions
        /overview#delayed-capture)
        for more information.

        Args:
            location_id (string): TODO: type description here.
            transaction_id (string): TODO: type description here.

        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/locations/{location_id}/transactions/{transaction_id}/voidTr   r8   r   r   r   r   Nr   r=   r:   r   r   r   void_transaction   r@   z TransactionsApi.void_transactionr   )NNNN)__name__
__module____qualname____doc__r
   r   r7   r;   r?   rA   __classcell__r   r   r   r   r   
   s    W
4
9r   N)deprecationr   square.api_helperr   square.http.api_responser   square.api.base_apir   square.http.auth.o_auth_2r   r   r   r   r   r   <module>   s   