
    g                         S SK Jr  S SKJrJr  S SKJr  S SKJr  S SK	J
r
  S SKJr  S SKJr  \" S/ S	Q5      r " S
 S\
5      rg)    )
namedtuple)RequestSession)TwilioRestException)urlparse)
HttpClient)Response)ClientValidationJwtValidationPayloadmethodpathquery_stringall_headerssigned_headersbodyc                   P    \ rS rSrSS/r SS jr      SS jrS rS rS	 r	S
r
g)ValidationClient   authorizationhostc                 p    Xl         X0l        X l        X@l        U(       a  [	        5       U l        gSU l        g)a  
Build a ValidationClient which signs requests with private_key and allows Twilio to
validate request has not been tampered with.

:param str account_sid: A Twilio Account Sid starting with 'AC'
:param str api_key_sid: A Twilio API Key Sid starting with 'SK'
:param str credential_sid: A Credential Sid starting with 'CR',
                           corresponds to public key Twilio will use to verify the JWT.
:param str private_key: The private key used to sign the Client Validation JWT.
N)account_sidcredential_sidapi_key_sidprivate_keyr   session)selfr   r   r   r   pool_connectionss         e/Users/Alptekin/Desktop/izin_takip/venv/lib/python3.13/site-packages/twilio/http/validation_client.py__init__ValidationClient.__init__   s-    $ ',&&$4wy$    Nc	           	      L   U R                   =(       d
    [        5       n	[        UR                  5       X#XEUS9n
U	R	                  U
5      nSUR
                  ;  a.  SUR
                  ;  a  U R                  U5      UR
                  S'   U R                  U5      n[        U R                  U R                  U R                  U R                  U5      nUR                  5       UR
                  S'   U	R                  UUUS9n[        [!        UR"                  5      UR$                  5      $ )ap  
Make a signed HTTP Request

: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
)paramsdataheadersauthHostr   zTwilio-Client-Validation)allow_redirectstimeout)r   r   r   upperprepare_requestr'   	_get_host_build_validation_payloadr
   r   r   r   r   to_jwtsendr	   intstatus_codetext)r   r   urlr%   r&   r'   r(   r+   r*   r   requestprepared_requestvalidation_payloadjwtresponses                  r    r6   ValidationClient.request-   s   6 ,,+')LLNCTQU
 #227; *222.666/3~~>N/O$$V,!;;<LM!
 @Czz|  !;<<<+   
 H0018==AAr#   c           	          [        UR                  5      nUR                  nUR                  =(       d    Sn[	        UR
                  UUUR                  [        R                  UR                  =(       d    SS9$ )z
Extract relevant information from request to build a ClientValidationJWT
:param PreparedRequest request: request we will extract information from.
:return: ValidationPayload
 r   )
r   r5   r   queryr   r   r'   r   !_ValidationClient__SIGNED_HEADERSr   )r   r6   parsedr   r   s        r    r/   *ValidationClient._build_validation_payloadf   s_     '++&{{||)r >>%+<<#
 	
r#   c                 V    [        UR                  5      n[        UR                  5      $ )z Pull the Host out of the request)r   r5   strnetloc)r   r6   r@   s      r    r.   ValidationClient._get_hosty   s    '++&6==!!r#   c                     UR                  SS5      nUR                  S:  d  UR                  S:  a  [        UR                  SS5      eg)z
Validate that a request to the new SSL certificate is successful
:return: null on success, raise TwilioRestException if the request fails
GETzhttps://tls-test.twilio.com:443   i,  z"Failed to validate SSL certificateN)r6   r3   r   )r   clientr:   s      r    validate_ssl_certificate)ValidationClient.validate_ssl_certificate~   sR    
 >>%)JK#%)=)=)D%$$14  *Er#   )r   r   r   r   r   )T)NNNNNF)__name__
__module____qualname____firstlineno__r?   r!   r6   r/   r.   rJ   __static_attributes__ r#   r    r   r      sA    '0 ?8 7Br
&"
r#   r   N)collectionsr   requestsr   r   twilio.base.exceptionsr   urllib.parser   twilio.httpr   twilio.http.responser	   twilio.jwt.validationr
   r   r   rQ   r#   r    <module>rY      s;    " % 6 ! " ) 5 O xz xr#   