
    pi-                         d dl Z d dlZd dlmZmZm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  ej$                  d      Z G d	 d
e      Zy)    N)DictOptionalTuple)RequestSessionhooks)HTTPAdapter)
HttpClient)r   )Responseztwilio.http_clientc                   
    e Zd ZdZdddeddfdedeeee	f      dee
   dej                  deeeef      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 xZS )TwilioHttpClientzI
    General purpose HTTP Client for interacting with the Twilio API
    TNpool_connectionsrequest_hookstimeoutloggerproxymax_retriesc           
         t         |   |d|       |r
t               nd| _        | j                  r)|'| j                  j	                  dt        |             nQ| j                  E| j                  j	                  dt        t        dt        j                         dz                      |xs t        j                         | _        |r|| _        yi | _        y)a  
        Constructor for the TwilioHttpClient
        :param pool_connections
        :param request_hooks
        :param timeout: Timeout for the requests.
                    Timeout should never be zero (0) or less
        :param logger
        :param proxy: Http proxy for the requests session
        :param max_retries: Maximum number of retries each request should attempt
        FNzhttps://)r          )pool_maxsize)super__init__r   sessionmountr	   minos	cpu_countr   default_hooksr   r   )selfr   r   r   r   r   r   	__class__s          Y/opt/services/ai/voice_agent/venv/lib/python3.12/site-packages/twilio/http/http_client.pyr   zTwilioHttpClient.__init__   s    & 	0$4wy$<<K3LLz;;+OP\\%LLKSR\\^a=O5PQ +Ce.A.A.C#U

    methodurlparamsdataheadersauthallow_redirectsreturnc	                    || j                   }n|dk  rt        |      |j                         ||||| j                  d}	|r|j	                  d      dk(  r||	d<   n!|r|j	                  d      dk(  r||	d<   n||	d<   | j                  |	       d| _        | j                  xs
 t               }
t        d
i |	}t        d
i |	| _        |
j                  |      }|
j                  |j                  | j                  ddd      } |
j                   |f||d	|}| j#                  |j$                  |       t'        t)        |j$                        |j*                  |j,                        | _        | j                  S )aj  
        Make an 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
        :param timeout: Socket/Read timeout for the request
        :param allow_redirects: Whether to allow redirects
        See the requests documentation for explanation of all these parameters

        :return: An HTTP response
        Nr   )r$   r%   r&   r(   r)   r   zContent-Typezapplication/jsonjsonzapplication/scim+jsonr'   )r*   r    )r   
ValueErrorupperr   getlog_request_test_only_last_responser   r   r   TwilioRequest_test_only_last_requestprepare_requestmerge_environment_settingsr%   r   sendlog_responsestatus_coder   inttextr(   )r    r$   r%   r&   r'   r(   r)   r   r*   kwargsr   requestprepped_requestsettingsresponses                  r"   r>   zTwilioHttpClient.request2   s   4 ?llG\W%% lln''
 w{{>26HH!F6N^48OO!F6N!F6N (,%,,+')#F#'4'>v'>$!11':55T4
  7<<
+
 	
 	(..9(0$$%x}}h6F6F)
% ,,,r#   )NNNNNF)__name__
__module____qualname____doc___loggerboolr   r   strobjectfloatloggingLoggerr;   r   r   r   r>   __classcell__)r!   s   @r"   r   r      s8    "&59#'!(*.%),,  S&[ 12, %	,
 , S#X', c],D /3,0,0*.#' %E-E- E- c6k*+	E-
 tCK()E- $sCx.)E- uS#X'E- %E- E- 
E-r#   r   )r   rK   typingr   r   r   requestsr   r   r   requests.adaptersr	   twilio.httpr
   twilio.http.requestr4   twilio.http.responser   	getLoggerrF   r   r.   r#   r"   <module>rU      sD    	  ( ( , , ) " 8 )
'

0
1h-z h-r#   