o
    O`6                     @   sv   d dl Z d dlmZmZmZ 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 e dZG d	d
 d
e
ZdS )    N)RequestSessionhooks)HTTPAdapter)	urlencode)
HttpClient)r   )Responseztwilio.http_clientc                   @   s4   e Zd ZdZdddeddfddZ		d	ddZdS )
TwilioHttpClientzI
    General purpose HTTP Client for interacting with the Twilio API
    TNc                 C   sz   |rt  nd| _| jr|dur| jdt|d d| _d| _|| _|p't | _	|dur5|dkr5t
||| _|| _dS )a  
        Constructor for the TwilioHttpClient

        :param bool pool_connections
        :param request_hooks
        :param int timeout: Timeout for the requests.
                            Timeout should never be zero (0) or less.
        :param logger
        :param dict proxy: Http proxy for the requests session
        :param int max_retries: Maximum number of retries each request should attempt
        Nzhttps://)max_retriesr   )r   sessionmountr   last_requestlast_responseloggerr   default_hooksrequest_hooks
ValueErrortimeoutproxy)selfpool_connectionsr   r   r   r   r
    r   [/var/www/html/asistente-voz-ia/venv/lib/python3.10/site-packages/twilio/http/http_client.py__init__   s   
zTwilioHttpClient.__init__Fc	                 C   sD  |dur|dkrt || |||||| jd}	|r8| jdjddt|i|	 | jdjdi |	 n| jdjdi |	 |rR| jdjdi |	 d| _| jpZt	 }
| j
rb| j
|
_tdi |	}tdi |	| _|
|}|
j|||dur|n| jd	}| jd
j||j|jd tt|j|j|j| _| jS )a  
        Make an HTTP Request with parameters provided.

        :param str method: The HTTP method to use
        :param str url: The URL to request
        :param dict params: Query parameters to append to the URL
        :param dict data: Parameters to go in the body of the HTTP request
        :param dict headers: HTTP Headers to send with the request
        :param tuple auth: Basic Auth arguments
        :param float timeout: Socket/Read timeout for the request
        :param boolean allow_redirects: Whether or not to allow redirects
        See the requests documentation for explanation of all these parameters

        :return: An http response
        :rtype: A :class:`Response <twilio.rest.http.response.Response>` object
        Nr   )methodurlparamsdataheadersauthr   z{method} Request: {url}?{query}queryzPARAMS: {params}z{method} Request: {url}zPAYLOAD: {data})allow_redirectsr   z"{method} Response: {status} {text})r   statustextr   )r   upperr   r   infoformatr   r   r   r   r   proxiesr   TwilioRequestr   prepare_requestsendr   status_coder#   r   intr   )r   r   r   r   r   r   r   r   r!   kwargsr   requestprepped_requestresponser   r   r   r.   ,   sB   
 


zTwilioHttpClient.request)NNNNNF)__name__
__module____qualname____doc___loggerr   r.   r   r   r   r   r	      s    

r	   )loggingrequestsr   r   r   requests.adaptersr   twilio.compatr   twilio.httpr   twilio.http.requestr(   twilio.http.responser   	getLoggerr5   r	   r   r   r   r   <module>   s    
