
    !+h                         d dl Z d dlmZmZmZ d dlmZmZ d dlm	Z	m
Z
 d dlmZ d dlmZ d dlmZ  e j        d          Z G d	 d
e          ZdS )    N)DictOptionalTuple)	BasicAuthClientSession)ExponentialRetryRetryClient)AsyncHttpClient)Request)Responseztwilio.async_http_clientc                   <    e Zd ZdZdddeddfdedee         dej	        dee
         dee         f
 fd	Z	 	 	 	 	 	 dde
de
deee
ef                  deee
ef                  deee
e
f                  deee
e
f                  dee         dedefdZd Zd Zd Z xZS )AsyncTwilioHttpClientzV
    General purpose asynchronous HTTP Client for interacting with the Twilio API
    TNpool_connectionstimeoutlogger	proxy_urlmax_retriesc                    t                                          |d|           || _        || _        |rt	          | j                  nd| _        |-t          |          }t          | j        |          | _        dS dS )a  
        Constructor for the AsyncTwilioHttpClient

        :param pool_connections: Creates a client session for making requests from.
        :param trace_configs: Configuration used to trace request lifecycle events. See aiohttp library TraceConfig
                              documentation for more info.
        :param timeout: Timeout for the requests (seconds)
        :param logger
        :param proxy_url: Proxy URL
        :param max_retries: Maximum number of retries each request should attempt
        T)trace_configsN)attempts)client_sessionretry_options)super__init__r   r   r   sessionr   r	   )	selfr   r   r   r   r   r   r   	__class__s	           a/var/www/html/e360mart/e360mart_env/lib/python3.11/site-packages/twilio/http/async_http_client.pyr   zAsyncTwilioHttpClient.__init__   s    ( 	w///"*  M(:;;;; 	
 ",kBBBM&#|=  DLLL #"    Fmethodurlparamsdataheadersauthallow_redirectsreturnc	           	      b  K   ||dk    rt          |          d}	|t          |d         |d                   }	|                                |||||	||d}
|                     |
           d| _        d}d}| j        r| j        }nt                      }d}t          di |
| _         |j	        di |
 d{V }| 
                    |j        |           t          |j        |                                 d{V |j                  | _        |r|                                 d{V  | j        S )	a  
        Make an asynchronous HTTP Request with parameters provided.

        :param method: The HTTP method to use
        :param url: The URL to request
        :param params: Query parameters to append to the URL
        :param data: Parameters to go in the body of the HTTP request
        :param headers: HTTP Headers to send with the request
        :param auth: Basic Auth arguments (username, password entries)
        :param timeout: Socket/Read timeout for the request. Overrides the timeout if set on the client.
        :param allow_redirects: Whether or not to allow redirects
        See the requests documentation for explanation of all these parameters

        :return: An http response
        Nr      )loginpassword)r    r!   r"   r#   r$   r%   r   r&   FT )
ValueErrorr   upperlog_request_test_only_last_responser   r   TwilioRequest_test_only_last_requestrequestlog_responsestatusr   textr$   close)r   r    r!   r"   r#   r$   r%   r   r&   
basic_authkwargstempr   responses                 r   r3   zAsyncTwilioHttpClient.request5   s     4 7a<<W%%%
"a47CCCJ llnn.	
 	
 	   (,%< 	lGG#ooGD'4'>'>v'>'>$(22622222222(/8444(0O8==??222222H4D)
 )
%  	"--//!!!!!!!,,r   c                 Z   K   | j         r!| j                                          d{V  dS dS )z0
        Closes the HTTP client session
        Nr   r7   r   s    r   r7   zAsyncTwilioHttpClient.closeu   H       < 	',$$&&&&&&&&&&&	' 	'r   c                 
   K   | S )z-
        Async context manager setup
        r,   r>   s    r   
__aenter__z AsyncTwilioHttpClient.__aenter__|   s       r   c                 Z   K   | j         r!| j                                          d{V  dS dS )z,
        Async context manager exit
        Nr=   )r   excinfos     r   	__aexit__zAsyncTwilioHttpClient.__aexit__   r?   r   )NNNNNF)__name__
__module____qualname____doc___loggerboolr   floatloggingLoggerstrintr   r   objectr   r   r3   r7   rA   rD   __classcell__)r   s   @r   r   r      s         "&#'!(#'%)     %	 
   C=  c]           L /3,0,0*.#' %>- >->- >- c6k*+	>-
 tCK()>- $sCx.)>- uS#X'>- %>- >- 
>- >- >- >-@' ' '  ' ' ' ' ' ' 'r   r   )rL   typingr   r   r   aiohttpr   r   aiohttp_retryr   r	   twilio.httpr
   twilio.http.requestr   r1   twilio.http.responser   	getLoggerrI   r   r,   r   r   <module>rY      s     ( ( ( ( ( ( ( ( ( ( , , , , , , , , 7 7 7 7 7 7 7 7 ' ' ' ' ' ' 8 8 8 8 8 8 ) ) ) ) ) )
'
6
7
7y' y' y' y' y'O y' y' y' y' y'r   