o
    nYi8                     @   sv  z
d dl mZmZ W n ey   d dlmZmZ Y nw 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 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 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% d dl&Z&d dl'm(Z( d dl)Z)dd Z*d)ddZ+d)ddZ,dd Z-d)ddZ.dd Z/d)dd Z0d)d!d"Z1d#d$ Z2d%d& Z3G d'd( d(eZdS )*    )urlparseParseResult)Client)Api)TwilioRestException)deserialize)ApplicationInstance)AccountInstance)CallInstance)RecordingInstance)TranscriptionInstance)MessageInstance)LocalInstance)TollFreeInstance)IncomingPhoneNumberInstance)Fax)V1Nuc                 C   s   dd }dd }dd }dd }d	d
 }t tjdrTtj rTdj|d|d|d| j| jf |d|t| jd}| j	rRd
|dj|d||| j	dg}|S d| j| jS )z@ Try to pretty-print the exception, if this is going on screen. c                 S      t d|  S )Nz[31m[49m%s[0mr   words r   \/var/www/html/asistente-voz-ia/venv/lib/python3.10/site-packages/signalwire/rest/__init__.pyred      zpatched_str.<locals>.redc                 S   r   )Nz[37m[49m%s[0mr   r   r   r   r   white!   r   zpatched_str.<locals>.whitec                 S   r   )Nz[34m[49m%s[0mr   r   r   r   r   blue$   r   zpatched_str.<locals>.bluec                 S   r   )Nz[36m[49m%s[0mr   r   r   r   r   teal'   r   zpatched_str.<locals>.tealc                 S   s
   d | S )Nz*https://www.signalwire.com/docs/errors/{0})format)coder   r   r   get_uri*   s   
zpatched_str.<locals>.get_uriisattyzB
{red_error} {request_was}

{http_line}

{sw_returned}

{message}
z
HTTP ErrorzYour request was:z%s %sz.Signalwire returned the following information:)	red_errorrequest_was	http_linesw_returnedmessage z
{more_info}

{uri}

z'More information may be available here:)	more_infourizHTTP {0} error: {1})hasattrsysstderrr"   r   methodr*   strmsgr    joinstatus)selfr   r   r   r   r!   r0   r   r   r   patched_str   s0   


r4   c                 C   s  t t| | i d|d d|d dt|d dt|d d|d d|ddd|d d	|d	 d
|d
 d|d d|d d|d d|d d|d d|d d|d d|d |d |d |d d| _d| _||p~| jd d| _dS )z
    Initialize the ApplicationInstance

    :returns: twilio.rest.api.v2010.account.application.ApplicationInstance
    :rtype: twilio.rest.api.v2010.account.application.ApplicationInstance
    account_sidapi_versiondate_createddate_updatedfriendly_namemessage_status_callbackr(   sidsms_fallback_methodsms_fallback_url
sms_methodsms_status_callbacksms_urlstatus_callbackstatus_callback_methodr*   voice_caller_id_lookupvoice_fallback_methodvoice_fallback_urlvoice_method	voice_url)rE   rF   rG   Nr5   r;   )	superr   __init__r   rfc2822_datetimeget_properties_context	_solutionr3   versionpayloadr5   r;   r   r   r    patched_applicationinstance_initD   sT   	

rS   c                 C   s   t t| | |d t|d t|d |d |dd|d |d |d	 |d
 |d d
| _d| _d|p<| jd i| _dS )z
        Initialize the AccountInstance
        :returns: twilio.rest.api.v2010.account.AccountInstance
        :rtype: twilio.rest.api.v2010.account.AccountInstance
        
auth_tokenr7   r8   r9   owner_account_sidr(   r;   r2   subresource_uristyper*   )
rT   r7   r8   r9   rU   r;   r2   rV   rW   r*   N)	rI   r	   rJ   r   rK   rL   rM   rN   rO   )r3   rQ   rR   r;   r   r   r   patched_accountinstance_initi   s   
rX   c                 C      t t| | |d |d |d |dd|d t|d t|d |d	 |d
 |d |d |d d| _d| _||d| _dS )z
    Initialize the LocalInstance
    :returns: twilio.rest.api.v2010.account.available_phone_number.local.LocalInstance
    :rtype: twilio.rest.api.v2010.account.available_phone_number.local.LocalInstance
    r9   phone_numberlatalocalityr(   rate_centerlatitude	longituderegionpostal_codeiso_countrybetacapabilitiesr9   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   Nr5   country_code)	rI   r   rJ   rL   r   decimalrM   rN   rO   r3   rQ   rR   r5   rg   r   r   r   patched_localinstance_init   s    
rj   c                 C   s`  t t| | i d|ddd|ddd|ddd|d d|d d|d dt|d d	t|d	 d
|d
 d|ddd|d d|ddd|d d|d d|d d|d d|d |d |d |d |dd|d |d |d |d |d |d |d |dd|ddd | _d!| _||p| jd d"| _d!S )#z
    Initialize the IncomingPhoneNumberInstance

    :returns: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberInstance
    :rtype: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberInstance
    r5   r(   address_sidaddress_requirementsr6   rc   rd   r7   r8   r9   identity_sidrZ   originr;   sms_application_sidr<   r=   r>   r@   rA   rB   	trunk_sidr*   voice_application_sidrC   rD   rE   rF   rG   emergency_statusemergency_address_sid)r@   rA   rB   rp   r*   rq   rC   rD   rE   rF   rG   rr   rs   NrH   )	rI   r   rJ   rL   r   rK   rM   rN   rO   rP   r   r   r   (patched_incomingphonenumberinstance_init   sh   	




"rt   c                 C   rY   )z
    Initialize the TollFreeInstance

    :returns: twilio.rest.api.v2010.account.available_phone_number.toll_free.TollFreeInstance
    :rtype: twilio.rest.api.v2010.account.available_phone_number.toll_free.TollFreeInstance
    r9   rZ   r[   r\   r(   r]   r^   r_   r`   ra   rb   rc   rd   re   Nrf   )	rI   r   rJ   rL   r   rh   rM   rN   rO   ri   r   r   r   patched_tollfreeinstance_init   s    
ru   c                 C   s  t t| | i d|d d|d d|d d|d dt|d dt|d dt|d d|d d	|d	 d
t|d
 d|d d|ddd|d d|d dt|ddd|d dt|d | _d| _	||p| jd	 d| _
dS )z
    Initialize the RecordingInstance
    :returns: twilio.rest.api.v2010.account.call.recording.RecordingInstance
    :rtype: twilio.rest.api.v2010.account.call.recording.RecordingInstance
    r5   r6   call_sidconference_sidr7   r8   
start_timedurationr;   pricer*   encryption_detailsr(   
price_unitr2   channels   source
error_codeNrH   )rI   r   rJ   r   rK   rh   rL   integerrM   rN   rO   rP   r   r   r   patched_recordinginstance_init   sL   	
r   c                 C   s   t t| | |d |d t|d t|d |d t|d |d |d |d	 |d
 |d |dd|d d| _d| _||pH| jd	 d| _	dS )z
      Initialize the TranscriptionInstance
      :returns: twilio.rest.api.v2010.account.transcription.TranscriptionInstance
      :rtype: twilio.rest.api.v2010.account.transcription.TranscriptionInstance
      r5   r6   r7   r8   ry   rz   r|   recording_sidr;   r2   transcription_textrW   r(   r*   )r5   r6   r7   r8   ry   rz   r|   r   r;   r2   r   rW   r*   NrH   )
rI   r   rJ   r   rK   rh   rL   rM   rN   rO   rP   r   r   r   "patched_transcriptioninstance_init  s"   
r   c                 C   s(   t t| | d| _|j| _d| _dS )zX
  Initialize the Fax Domain
  :returns: Domain for Fax
  :rtype: twilio.rest.fax.Fax
  r(   N)rI   	TwilioFaxrJ   base_urlr5   _v1)r3   twilior   r   r   patched_fax_init,  s   
r   c                 C   s&   t t| | d|j | _d| _dS )zg
  Initialize the V1 version of Fax
  :returns: V1 version of Fax
  :rtype: twilio.rest.fax.v1.V1.V1
  z2010-04-01/Accounts/N)rI   TwilioV1rJ   r5   rQ   _faxes)r3   domainr   r   r   patched_fax_v1_init:  s   
r   c                       s   e Zd Z fddZ  ZS )r   c                    s   d|v r| dd}ntjd }t|d}|jp|j}|jr!|jnd}td||g|dd  R  }tt| j	|i | t
| | _| | j_tt_	tt_	t| | _| | j_tt_tt_	tt_	tt_	tt_	tt_	t t!_	t"t#_	d S )Nsignalwire_space_urlzapi.signalwire.comSIGNALWIRE_SPACE_URLhttpr(   https   )$poposenvironr   netlocpathr   rI   r   rJ   	TwilioApi_apigeturlr   r   r   r   r   _faxr4   r   __str__rX   r	   rj   r   ru   r   rS   r   rt   r   r   r   r   r   )r3   argskwargsr   pr   r   	__class__r   r   rJ   F  s,   




zClient.__init__)__name__
__module____qualname__rJ   __classcell__r   r   r   r   r   E  s    r   )N)4urllib.parser   r   ImportErrortwilio.restr   TwilioClienttwilio.rest.apir   r   twilio.base.exceptionsr   twilio.baser   )twilio.rest.api.v2010.account.applicationr   twilio.rest.api.v2010.accountr	   "twilio.rest.api.v2010.account.callr
   'twilio.rest.api.v2010.account.recordingr   +twilio.rest.api.v2010.account.transcriptionr   %twilio.rest.api.v2010.account.messager   :twilio.rest.api.v2010.account.available_phone_number.localr   >twilio.rest.api.v2010.account.available_phone_number.toll_freer   3twilio.rest.api.v2010.account.incoming_phone_numberr   twilio.rest.faxr   r   twilio.rest.fax.v1r   r   r,   sixr   r   r4   rS   rX   rj   rt   ru   r   r   r   r   r   r   r   r   <module>   sD    
)
%
/

#