HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/buyercall/buyercall/lib/__pycache__/bandwidth_bxml.cpython-310.pyc
o

�weO�@s�ddlZddlZddlZddlmmZddlmZddl	Z	ddl
Z
ddlmZddl
mZe�e�ZdZdd�Zdd	�ZGd
d�de�ZGdd
�d
e�ZGdd�de�ZdS)�N)�parseString)�
HTTPBasicAuth)�urlparse��cCsJt|t�rdd�|��D�S|�d�}|dd�dd�|dd�D��S)	NcSsi|]	\}}t|�|�qS�)�
camel_case)�.0�key�valrr�>/home/arjun/projects/buyercall/buyercall/lib/bandwidth_bxml.py�
<dictcomp>szcamel_case.<locals>.<dictcomp>�_r�css�|]}|��VqdS�N)�
capitalize)r�xrrr�	<genexpr>s�zcamel_case.<locals>.<genexpr>�)�
isinstance�dict�items�split�join)�thing�wordsrrrrs

$rcCs(tt|��}|��}t�d�|��|S)z8 Transform a Twiml Response to a Flask response object. zThe XML looks like: {})r�str�toprettyxml�log�info�format)�r�xml�resultrrr�create_xml_responsesr#c@s�eZdZd*dd�Zdd�Zdd�Zd+d	d
�Zd,d
d�Zdd�Zd-dd�Z	dd�Z
dd�Zdd�Z		d.d d!�Z
		d/d"d#�Zd$d%�Zd&d'�Zd(d)�ZdS)0�ResponseNcCs"|dur	||_dSt�d�|_dS)Nr$)�ET�Element�root��self�eltrrr�__init__$s"zResponse.__init__cCstj|jdd�S)N�unicode)�encoding)r%�tostringr'�r)rrr�__str__'szResponse.__str__cC�t�d�}|j�|�|S)N�Hangup�r%r&r'�appendr(rrr�hangup*�
zResponse.hangup�2cCstjd|d�}|j�|�|S)N�Pause)�durationr3)r)�lengthr*rrr�custom_pause/s
�zResponse.custom_pause�5�truecCs tjd||d�}|j�|�|S)N�Ring)r9�
answerCallr3)r)r9�answer_callr*rrr�ring6s
�z
Response.ringcC� t�d�}||_|j�|�|S�N�	PlayAudio�r%r&�textr'r4�r)�urlr*rrr�
play_audio=�
zResponse.play_audio�female�en_US�susancCs(tjd|||d�}||_|j�|�|S)N�
SpeakSentence)�gender�locale�voicerE)r)rFrOrPrQr*rrr�sayCs�zResponse.saycCrB)N�TagrE)r)rFr*rrr�tagK��zResponse.tagcCrB)N�BridgerE)r)�call_idr*rrr�bridgeSrUzResponse.bridgecKsJtjd||d�}|j�|�|��D]\}}|r"|�t|�t|��q|S)N�Redirect)�redirectUrl�redirectFallbackUrl�r%r&r'r4r�setrr)r)�redirect_url�redirect_fallback_url�kwargsr*r	r
rrr�redirect[s��zResponse.redirect�#�5400�60�mp3c
KsTtjd|||||||d�}	|j�|	�|��D]\}
}|r'|	�t|
�t|��q|	S)N�Record)�recordingAvailableUrl�
transcribe�transcriptionAvailableUrl�terminatingDigits�maxDuration�silenceTimeout�
fileFormatr\)r)�recording_available_urlrh�transcribe_available_url�terminating_digits�max_duration�silence_timeout�file_formatr`r*r	r
rrr�recordgs �
�zResponse.recordc
KsPtjd|||||d�}|j�|�|��D]\}}	|	r%|�t|�t|	��q|S)N�StartRecording)rgrhrirm�multiChannelr\)
r)rnrhrors�
multi_channelr`r*r	r
rrr�start_recordzs��zResponse.start_recordcCr1)N�
StopRecordingr3r(rrr�
end_record�r6zResponse.end_recordc	KsRtjd||||d�}|j�|�|��D]\}}|r$|�t|�t|��qt|�S)N�Transfer)�transferCallerId�callTimeout�transferCompleteUrl�transferCompleteFallbackUrl)	r%r&r'r4rr]rrr{)	r)�	caller_id�call_timeout�transfer_complete_url�transfer_complete_fallback_urlr`r*r	r
rrr�transfer�s��zResponse.transfercKsNtjd||d�}|j�|�|��D]\}}|r"|�t|�t|��qt|�S)N�Gather)�	gatherUrl�gatherFallbackUrl)	r%r&r'r4rr]rrr�)r)�
gather_url�gather_fallback_urlr`r*r	r
rrr�gather�s��zResponse.gatherr)r7)r<r=)rKrLrM)rbrcrdre)rer=)�__name__�
__module__�__qualname__r+r0r5r;rArIrRrTrXrartrxrzr�r�rrrrr$#s(





�
�r$c@�4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)r{cCs||_t|j�|_dSr)r'r$�respr(rrrr+�szTransfer.__init__cC�|Srrr/rrr�	__enter__��zTransfer.__enter__cC�dSrr�r)�type_�value�tbrrr�__exit__�r�zTransfer.__exit__c	K�Rtjd|||d�}|j�|�|��D]\}}|r#|�t|�t|��q||_|S)N�PhoneNumber��transferAnswerUrl�transferAnswerFallbackUrl�transferDisconnectUrl�	r%r&r'r4rr]rrrF�	r)rF�transfer_answer_url�transfer_answer_fallback_url�transfer_disconnect_urlr`r*r	r
rrr�phone_number����zTransfer.phone_numberc	Kr�)N�SipUrir�r�r�rrr�sip_uri�r�zTransfer.sip_uriN)r�r�r�r+r�r�r�r�rrrrr{�sr{c@r�)r�cCs
||_dSr)r'r(rrrr+�s
zGather.__init__cCr�rrr/rrrr��r�zGather.__enter__cCr�rrr�rrrr��r�zGather.__exit__cOst|j�j|i|��Sr)r$r'rR)r)�argsr`rrrrR�sz
Gather.saycCrBrCrErGrrrrI�rJzGather.play_audioN)r�r�r�r+r�r�rRrIrrrrr��sr�)�os�json�logging�xml.etree.ElementTree�etree�ElementTreer%�xml.dom.minidomr�	xmltodict�requests�
requests.authr�urllib.parser�	getLoggerr�r�success_status_coderr#�objectr$r{r�rrrr�<module>s"
	
+