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 Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd Z  ZS )TerminalApiz3A Controller to access Endpoints in the square API.Nc                    s   t t| || d S N)superr   __init__)selfconfig	call_back	__class__ n/var/www/html/riverr-enterprise-integrations-main/venv/lib/python3.10/site-packages/square/api/terminal_api.pyr	      s   zTerminalApi.__init__c                 C      d}| j  }||7 }t|}ddd}| j jj||t|d}t| j | | 	|}t
|j}t|tu r@|d}	nd}	t|||	d}
|
S )a[  Does a POST request to /v2/terminals/checkouts.

        Creates a Terminal checkout request and sends it to the specified
        device to take a payment
        for the requested amount.

        Args:
            body (CreateTerminalCheckoutRequest): An object containing the
                fields to POST for the request.  See the corresponding object
                definition for field details.

        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/terminals/checkoutsapplication/jsonacceptzContent-Typeheaders
parameterserrorsNbodyr   r   get_base_urir   	clean_urlhttp_clientpostjson_serializer   applyexecute_requestjson_deserializetexttypedictgetr   r
   r   	_url_path_query_builder
_query_url_headers_request	_responsedecoded_errors_resultr   r   r   create_terminal_checkout   s    


z$TerminalApi.create_terminal_checkoutc                 C   r   )aI  Does a POST request to /v2/terminals/checkouts/search.

        Retrieves a filtered list of Terminal checkout requests created by the
        account making the request.

        Args:
            body (SearchTerminalCheckoutsRequest): An object containing the
                fields to POST for the request.  See the corresponding object
                definition for field details.

        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/terminals/checkouts/searchr   r   r   r   Nr   r   r(   r   r   r   search_terminal_checkoutsB       


z%TerminalApi.search_terminal_checkoutsc                 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/terminals/checkouts/{checkout_id}.

        Retrieves a Terminal checkout request by `checkout_id`.

        Args:
            checkout_id (string): The unique ID for the desired
                `TerminalCheckout`.

        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/terminals/checkouts/{checkout_id}checkout_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
   r6   r)   r*   r+   r,   r-   r.   r/   r0   r1   r   r   r   get_terminal_checkouts   $   



z!TerminalApi.get_terminal_checkoutc                 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 POST request to /v2/terminals/checkouts/{checkout_id}/cancel.

        Cancels a Terminal checkout request if the status of the request
        permits it.

        Args:
            checkout_id (string): The unique ID for the desired
                `TerminalCheckout`.

        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/terminals/checkouts/{checkout_id}/cancelr6   Tr7   r   r   r:   r   Nr   r   r<   r   r   r   r   r   r   r!   r"   r#   r$   r%   r&   r'   r   r=   r   r   r   cancel_terminal_checkout   $   



z$TerminalApi.cancel_terminal_checkoutc                 C   r   )a)  Does a POST request to /v2/terminals/refunds.

        Creates a request to refund an Interac payment completed on a Square
        Terminal.

        Args:
            body (CreateTerminalRefundRequest): An object containing the
                fields to POST for the request.  See the corresponding object
                definition for field details.

        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/terminals/refundsr   r   r   r   Nr   r   r(   r   r   r   create_terminal_refund   r4   z"TerminalApi.create_terminal_refundc                 C   r   )aJ  Does a POST request to /v2/terminals/refunds/search.

        Retrieves a filtered list of Interac Terminal refund requests created
        by the seller making the request.

        Args:
            body (SearchTerminalRefundsRequest): An object containing the
                fields to POST for the request.  See the corresponding object
                definition for field details.

        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/terminals/refunds/searchr   r   r   r   Nr   r   r(   r   r   r   search_terminal_refunds  r4   z#TerminalApi.search_terminal_refundsc                 C   r5   )a  Does a GET request to /v2/terminals/refunds/{terminal_refund_id}.

        Retrieves an Interac Terminal refund object by ID.

        Args:
            terminal_refund_id (string): The unique ID for the desired
                `TerminalRefund`.

        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/terminals/refunds/{terminal_refund_id}terminal_refund_idTr7   r   r   r:   r   Nr   r;   r
   rF   r)   r*   r+   r,   r-   r.   r/   r0   r1   r   r   r   get_terminal_refund8  r?   zTerminalApi.get_terminal_refundc                 C   r@   )a  Does a POST request to /v2/terminals/refunds/{terminal_refund_id}/cancel.

        Cancels an Interac Terminal refund request by refund request ID if the
        status of the request permits it.

        Args:
            terminal_refund_id (string): The unique ID for the desired
                `TerminalRefund`.

        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.

        z1/v2/terminals/refunds/{terminal_refund_id}/cancelrF   Tr7   r   r   r:   r   Nr   rA   rG   r   r   r   cancel_terminal_refundi  rC   z"TerminalApi.cancel_terminal_refundr   )__name__
__module____qualname____doc__r	   r2   r3   r>   rB   rD   rE   rH   rI   __classcell__r   r   r   r   r   	   s    2112111r   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
   