
    =hF                       d dl mZ d dlZd dlmZmZmZ d dlmZm	Z	 d dl
Z
ddlmZ ddlmZ ddlmZmZmZmZmZmZmZ dd	lmZmZ dd
lmZ ddlmZmZmZm Z m!Z!m"Z"m#Z#m$Z$ ddl%m&Z&m'Z' ddlm(Z( ddl)m*Z*m+Z+m,Z, ddl-m.Z. g dZ/ G d de+      Z0 G d de,      Z1 G d d      Z2 G d d      Z3 G d d      Z4 G d d      Z5e0Z6e1Z7y)    )annotationsN)AnyUnionMapping)Selfoverride   )_exceptionsQuerystring)	NOT_GIVENOmitTimeoutNotGiven	TransportProxiesTypesRequestOptions)is_givenget_async_library)__version__)llmcallagentvoice
batch_callconcurrencyphone_numberknowledge_base)StreamAsyncStream)APIStatusError)DEFAULT_MAX_RETRIESSyncAPIClientAsyncAPIClient)verify)r   r   r   r   RetellAsyncRetellClientAsyncClientc                      e Zd ZU ded<   ded<   ded<   ded<   d	ed
<   ded<   ded<   ded<   ded<   ded<   ded<   deeddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d! fdZeed"d              Z	eed#d              Z
eed$ fd              Zddededdddi d
	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d%dZeZe	 	 	 	 	 	 	 	 d&d        Z xZS )'r&   zcall.CallResourcer   z phone_number.PhoneNumberResourcer   zagent.AgentResourcer   zllm.LlmResourcer   z$knowledge_base.KnowledgeBaseResourcer   zvoice.VoiceResourcer   zconcurrency.ConcurrencyResourcer   zbatch_call.BatchCallResourcer   RetellWithRawResponsewith_raw_responseRetellWithStreamedResponsewith_streaming_responsestrapi_keyNFbase_urltimeoutmax_retriesdefault_headersdefault_queryhttp_client_strict_response_validationc          
        || _         |t        j                  j                  d      }|d}t        	|   t        |||||||       t        j                  |       | _        t        j                  |       | _	        t        j                  |       | _        t        j                  |       | _        t        j                   |       | _        t#        j$                  |       | _        t'        j(                  |       | _        t+        j,                  |       | _        t/        |       | _        t3        |       | _        t6        | _        y)z3Construct a new synchronous Retell client instance.NRETELL_BASE_URLhttps://api.retellai.comversionr2   r4   r3   r7   custom_headerscustom_queryr8   )r0   osenvirongetsuper__init__r   r   CallResourcer   PhoneNumberResourcer   AgentResourcer   LlmResourcer   KnowledgeBaseResourcer   VoiceResourcer   ConcurrencyResourcer   BatchCallResourcer+   r,   r-   r.   r%   
selfr0   r2   r3   r4   r5   r6   r7   r8   	__class__s
            ^/var/www/html/phonemate/phone_mate_backend/venv/lib/python3.12/site-packages/retell/_client.pyrD   zRetell.__init__7   s   0 zz~~&78H1H##*&(C 	 		
 %%d+	(<<TB((.
??4(,BB4H((.
&::4@$66t<!6t!<'A$'G$    c                    t        d      S Nbrackets)array_formatr   rN   s    rP   qsz	Retell.qsn        
33rQ   c                (    | j                   }dd| iS NAuthorizationzBearer r0   rN   r0   s     rP   auth_headerszRetell.auth_headerss        ,,77)!455rQ   c                <    i t         |   ddi| j                  S )NX-Stainless-Asyncfalse)rC   r5   _custom_headersrN   rO   s    rP   r5   zRetell.default_headersy   s4    
g%

 ""
 	
rQ   
r0   r2   r3   r7   r4   r5   set_default_headersr6   set_default_query_extra_kwargsc       
           ||t        d      ||	t        d      | j                  }|i ||}n||}| j                  }|i ||}n|	|	}|xs | j                  } | j                  d|xs | j
                  |xs | j                  t        |t              r| j                  n||t        |      r|n| j                  ||d|
S z~
        Create a new client instance re-using the same options given to the current client with optional overriding.
        zPThe `default_headers` and `set_default_headers` arguments are mutually exclusivezLThe `default_query` and `set_default_query` arguments are mutually exclusive)r0   r2   r3   r7   r4   r5   r6    
ValueErrorrc   _custom_query_clientrO   r0   r2   
isinstancer   r3   r   r4   rN   r0   r2   r3   r7   r4   r5   rf   r6   rg   rh   headersparamss                rP   copyzRetell.copy       " &+>+Jopp$):)Fkll&&&44O4G ,)G##$00-0F*&F!1T\\t~~ 	
+t||.$.w$ADLLw#'/'<$BRBR# 	
 	
 		
rQ   c                  |j                   dk(  rt        j                  |||      S |j                   dk(  rt        j                  |||      S |j                   dk(  rt        j                  |||      S |j                   dk(  rt        j
                  |||      S |j                   dk(  rt        j                  |||      S |j                   dk(  rt        j                  |||      S |j                   dk(  rt        j                  |||      S |j                   d	k\  rt        j                  |||      S t        |||      S 
Ni  )responsebodyi  i  i  i  i  i  i  status_coder
   BadRequestErrorAuthenticationErrorPermissionDeniedErrorNotFoundErrorConflictErrorUnprocessableEntityErrorRateLimitErrorInternalServerErrorr!   rN   err_msgry   rx   s       rP   _make_status_errorzRetell._make_status_error   0    3&..wPTUU3&227XTXYY3&44WxVZ[[3&,,WxdSS3&,,WxdSS3&77(Y]^^3&--gtTT3&227XTXYYgtDDrQ   )r0   r/   r2   str | httpx.URL | Noner3   %Union[float, Timeout, None, NotGiven]r4   intr5   Mapping[str, str] | Noner6   Mapping[str, object] | Noner7   httpx.Client | Noner8   boolreturnNoner   r   r   zdict[str, str]r   zdict[str, str | Omit])r0   
str | Noner2   r   r3   !float | Timeout | None | NotGivenr7   r   r4   int | NotGivenr5   r   rf   r   r6   r   rg   r   rh   Mapping[str, Any]r   r   r   r/   ry   objectrx   zhttpx.Responser   r!   __name__
__module____qualname____annotations__r   r"   rD   propertyr   rW   r^   r5   rt   with_optionsr   __classcell__rO   s   @rP   r&   r&   (   s   
22	8800,,,,77 L ,09B.4859 ,0 -2+5 5 )	5
 75 5 25 35 )5* &*+5, 
-5n 4  4 6  6 
  
 #+/5>+/&/488<599=+--
 -
 )	-

 3-
 )-
 $-
 2-
 6-
 3-
 7-
 )-
 
-
b LEE 	E
 !E 
E ErQ   r&   c                      e Zd ZU ded<   ded<   ded<   ded<   d	ed
<   ded<   ded<   ded<   ded<   ded<   ded<   deeddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d! fdZeed"d              Z	eed#d              Z
eed$ fd              Zddededdddi d
	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d%dZeZe	 	 	 	 	 	 	 	 d&d        Z xZS )'r'   zcall.AsyncCallResourcer   z%phone_number.AsyncPhoneNumberResourcer   zagent.AsyncAgentResourcer   zllm.AsyncLlmResourcer   z)knowledge_base.AsyncKnowledgeBaseResourcer   zvoice.AsyncVoiceResourcer   z$concurrency.AsyncConcurrencyResourcer   z!batch_call.AsyncBatchCallResourcer   AsyncRetellWithRawResponser,   AsyncRetellWithStreamedResponser.   r/   r0   NFr1   c          
     t   || _         |t        j                  j                  d      }|d}t        	|   t        |||||||       t        j                  |       | _        t        j                  |       | _	        t        j                  |       | _        t        j                  |       | _        t        j                   |       | _        t#        j$                  |       | _        t'        j(                  |       | _        t+        j,                  |       | _        t/        |       | _        t3        |       | _        y)z2Construct a new async AsyncRetell client instance.Nr:   r;   r<   )r0   r@   rA   rB   rC   rD   r   r   AsyncCallResourcer   AsyncPhoneNumberResourcer   AsyncAgentResourcer   AsyncLlmResourcer   AsyncKnowledgeBaseResourcer   AsyncVoiceResourcer   AsyncConcurrencyResourcer   AsyncBatchCallResourcer   r,   r   r.   rM   s
            rP   rD   zAsyncRetell.__init__   s	   0 zz~~&78H1H##*&(C 	 		
 **40	(AA$G--d3
''-,GGM--d3
&??E$;;DA!;D!A'Ft'L$rQ   c                    t        d      S rS   r   rV   s    rP   rW   zAsyncRetell.qs  rX   rQ   c                (    | j                   }dd| iS rZ   r\   r]   s     rP   r^   zAsyncRetell.auth_headers   r_   rQ   c                R    i t         |   ddt                i| j                  S )Nra   zasync:)rC   r5   r   rc   rd   s    rP   r5   zAsyncRetell.default_headers&  s@    
g%
6*;*=)>!?
 ""
 	
rQ   re   c       
           ||t        d      ||	t        d      | j                  }|i ||}n||}| j                  }|i ||}n|	|	}|xs | j                  } | j                  d|xs | j
                  |xs | j                  t        |t              r| j                  n||t        |      r|n| j                  ||d|
S rj   rl   rq   s                rP   rt   zAsyncRetell.copy/  ru   rQ   c                  |j                   dk(  rt        j                  |||      S |j                   dk(  rt        j                  |||      S |j                   dk(  rt        j                  |||      S |j                   dk(  rt        j
                  |||      S |j                   dk(  rt        j                  |||      S |j                   dk(  rt        j                  |||      S |j                   dk(  rt        j                  |||      S |j                   d	k\  rt        j                  |||      S t        |||      S rw   rz   r   s       rP   r   zAsyncRetell._make_status_errorb  r   rQ   )r0   r/   r2   r   r3   r   r4   r   r5   r   r6   r   r7   httpx.AsyncClient | Noner8   r   r   r   r   r   r   )r0   r   r2   r   r3   r   r7   r   r4   r   r5   r   rf   r   r6   r   rg   r   rh   r   r   r   r   r   r   s   @rP   r'   r'      s   
  77##	==##551111<< L ,09B.4859 15 -2+3M 3M )	3M
 73M 3M 23M 33M .3M* &*+3M, 
-3Mj 4  4 6  6 
  
 #+/5>04&/488<599=+--
 -
 )	-

 3-
 .-
 $-
 2-
 6-
 3-
 7-
 )-
 
-
b LEE 	E
 !E 
E ErQ   r'   c                      e Zd ZddZy)r+   c                D   t        j                  |j                         | _         t        j                  |j                        | _        t	        j
                  |j                        | _        t        j                  |j                        | _        t        j                  |j                        | _        t        j                  |j                        | _
        t        j                  |j                        | _        t        j                  |j                        | _        y N)r   CallResourceWithRawResponser   "PhoneNumberResourceWithRawResponser   AgentResourceWithRawResponser   LlmResourceWithRawResponser   $KnowledgeBaseResourceWithRawResponser   VoiceResourceWithRawResponser   "ConcurrencyResourceWithRawResponser    BatchCallResourceWithRawResponserN   clients     rP   rD   zRetellWithRawResponse.__init__  s    44V[[A	(KKFL_L_`77E
11&**=,QQRXRgRgh77E
&II&J\J\]$EEfFWFWXrQ   Nr   r&   r   r   r   r   r   rD   rk   rQ   rP   r+   r+     s    YrQ   r+   c                      e Zd ZddZy)r   c                D   t        j                  |j                         | _         t        j                  |j                        | _        t	        j
                  |j                        | _        t        j                  |j                        | _        t        j                  |j                        | _        t        j                  |j                        | _
        t        j                  |j                        | _        t        j                  |j                        | _        y r   )r    AsyncCallResourceWithRawResponser   'AsyncPhoneNumberResourceWithRawResponser   !AsyncAgentResourceWithRawResponser   AsyncLlmResourceWithRawResponser   )AsyncKnowledgeBaseResourceWithRawResponser   !AsyncVoiceResourceWithRawResponser   'AsyncConcurrencyResourceWithRawResponser   %AsyncBatchCallResourceWithRawResponser   s     rP   rD   z#AsyncRetellWithRawResponse.__init__  s    99&++F	(PPQWQdQde<<V\\J
66vzzB,VVW]WlWlm<<V\\J
&NNvOaOab$JJ6K\K\]rQ   Nr   r'   r   r   r   rk   rQ   rP   r   r     s    ^rQ   r   c                      e Zd ZddZy)r-   c                D   t        j                  |j                         | _         t        j                  |j                        | _        t	        j
                  |j                        | _        t        j                  |j                        | _        t        j                  |j                        | _        t        j                  |j                        | _
        t        j                  |j                        | _        t        j                  |j                        | _        y r   )r   !CallResourceWithStreamingResponser   (PhoneNumberResourceWithStreamingResponser   "AgentResourceWithStreamingResponser    LlmResourceWithStreamingResponser   *KnowledgeBaseResourceWithStreamingResponser   "VoiceResourceWithStreamingResponser   (ConcurrencyResourceWithStreamingResponser   &BatchCallResourceWithStreamingResponser   s     rP   rD   z#RetellWithStreamedResponse.__init__  s    ::6;;G	(QQRXReRef==fllK
77

C,WWX^XmXmn==fllK
&OOPVPbPbc$KKFL]L]^rQ   Nr   r   rk   rQ   rP   r-   r-     s    _rQ   r-   c                      e Zd ZddZy)r   c                D   t        j                  |j                         | _         t        j                  |j                        | _        t	        j
                  |j                        | _        t        j                  |j                        | _        t        j                  |j                        | _        t        j                  |j                        | _
        t        j                  |j                        | _        t        j                  |j                        | _        y r   )r   &AsyncCallResourceWithStreamingResponser   -AsyncPhoneNumberResourceWithStreamingResponser   'AsyncAgentResourceWithStreamingResponser   %AsyncLlmResourceWithStreamingResponser   /AsyncKnowledgeBaseResourceWithStreamingResponser   'AsyncVoiceResourceWithStreamingResponser   -AsyncConcurrencyResourceWithStreamingResponser   +AsyncBatchCallResourceWithStreamingResponser   s     rP   rD   z(AsyncRetellWithStreamedResponse.__init__  s    ??L	(VVW]WjWjkBB6<<P
<<VZZH,\\]c]r]rsBB6<<P
&TTU[UgUgh$PPQWQbQbcrQ   Nr   r   rk   rQ   rP   r   r     s    drQ   r   )8
__future__r   r@   typingr   r   r   typing_extensionsr   r   httpx r
   _qsr   _typesr   r   r   r   r   r   r   _utilsr   r   _versionr   	resourcesr   r   r   r   r   r   r   r   
_streamingr   r    r!   _base_clientr"   r#   r$   lib.webhook_authr%   __all__r&   r'   r+   r   r-   r   r(   r)   rk   rQ   rP   <module>r      s    # 	 & & ,      " e e e D ' 
 %
vlE] lE^jE. jEZ	Y 	Y	^ 	^	_ 	_	d 	d 
rQ   