o
    ÚtBhd
  ã                   @   s    d dl mZ G dd„ deƒZdS )é    )Ú	APIHelperc                   @   sL   e Zd ZdZdd„ Zddd„Zedd„ ƒZed	d
„ ƒZdd„ Z	ddd„Z
dS )ÚBaseApia?  All controllers inherit from this base class.

    Attributes:
        config (Configuration): The HttpClient which a specific controller
            instance will use. By default all the controller objects share
            the same HttpClient. A user can use his own custom HttpClient
            as well.
        http_call_back (HttpCallBack): An object which holds call back
            methods to be called before and after the execution of an HttpRequest.
        global_headers (dict): The global headers of the API which are sent with
            every request.

    c                 C   s   d| j jdœS )Nz!Square-Python-SDK/16.0.0.20211117)z
user-agentzSquare-Version)ÚconfigÚsquare_version©Úself© r   új/var/www/html/riverr-enterprise-integrations-main/venv/lib/python3.10/site-packages/square/api/base_api.pyÚglobal_headers   s   þzBaseApi.global_headersNc                 C   s   || _ || _d S ©N)Ú_configÚ_http_call_back)r   r   Ú	call_backr   r   r	   Ú__init__   s   
zBaseApi.__init__c                 C   ó   | j S r   )r   r   r   r   r	   r       ó   zBaseApi.configc                 C   r   r   )r   r   r   r   r	   Úhttp_call_back$   r   zBaseApi.http_call_backc                 K   s,   |  ¡ D ]\}}|du rtd |¡ƒ‚qdS )zŠValidates required parameters of an endpoint.

        Args:
            kwargs (dict): A dictionary of the required parameters.

        Nz%Required parameter {} cannot be None.)ÚitemsÚ
ValueErrorÚformat)r   ÚkwargsÚnameÚvaluer   r   r	   Úvalidate_parameters(   s
   ÿÿzBaseApi.validate_parametersFc                 C   s€   | j dur| j  |¡ t |  ¡ |j¡|_| jjdur#|j | jj¡ |r*| jj	j
n| jj	j}||ƒ}| j dur>| j  |¡ |S )a'  Executes an HttpRequest.

        Args:
            request (HttpRequest): The HttpRequest to execute.
            binary (bool): A flag which should be set to True if
                a binary response is expected.

        Returns:
            HttpResponse: The HttpResponse received.

        N)r   Úon_before_requestr   Úmerge_dictsr
   Úheadersr   Úadditional_headersÚupdateÚhttp_clientÚexecute_as_binaryÚexecute_as_stringÚon_after_response)r   ÚrequestÚbinaryÚfuncÚresponser   r   r	   Úexecute_request3   s   

zBaseApi.execute_requestr   )F)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r
   r   Úpropertyr   r   r   r'   r   r   r   r	   r      s    


r   N)Úsquare.api_helperr   Úobjectr   r   r   r   r	   Ú<module>   s   