o
    �¨ÊhÞ
  ã                   @   sj   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
Z
d dlmZ e
 d¡ZG dd	„ d	eƒZdS )
é    )ÚRequestÚSessionÚhooks)Ú
HttpClient)ÚResponse)r   N)Ú	urlencodeztwilio.http_clientc                   @   s(   e Zd ZdZd	dd„Z		d
dd„ZdS )ÚTwilioHttpClientzI
    General purpose HTTP Client for interacting with the Twilio API
    TNc                 C   s.   |rt ƒ nd | _d | _d | _|pt ¡ | _d S )N)r   ÚsessionÚlast_requestÚlast_responser   Údefault_hooksÚrequest_hooks)ÚselfÚpool_connectionsr   © r   úI/var/www/html/env/lib/python3.10/site-packages/twilio/http/http_client.pyÚ__init__   s   zTwilioHttpClient.__init__Fc	                 C   s  |  ¡ |||||| jdœ}	|r*t djddt|ƒi|	¤Ž¡ t djdi |	¤Ž¡ nt djdi |	¤Ž¡ |rBt djdi |	¤Ž¡ d| _| jpJtƒ }
t	di |	¤Ž}t
di |	¤Ž| _|
 |¡}|
j|||d�}t d	j||j|jd
�¡ tt|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
        )ÚmethodÚurlÚparamsÚdataÚheadersÚauthr   z{method} Request: {url}?{query}ÚqueryzPARAMS: {params}z{method} Request: {url}zPAYLOAD: {data}N)Úallow_redirectsÚtimeoutz"{method} Response: {status} {text})r   ÚstatusÚtextr   )Úupperr   Ú_loggerÚinfoÚformatr   r   r	   r   r   ÚTwilioRequestr
   Úprepare_requestÚsendÚstatus_coder   r   Úint)r   r   r   r   r   r   r   r   r   Úkwargsr	   ÚrequestÚprepped_requestÚresponser   r   r   r(      s6   ù

ýzTwilioHttpClient.request)TN)NNNNNF)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r(   r   r   r   r   r      s    
ÿr   )Úrequestsr   r   r   Útwilio.httpr   Útwilio.http.responser   Útwilio.http.requestr"   ÚloggingÚtwilio.compatr   Ú	getLoggerr   r   r   r   r   r   Ú<module>   s    
