Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion bandwidth/models/bxml/verb.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ def _set_attributes(self, root: ET.Element):
if self._attributes is not None:
for key, value in self._attributes.items():
if value is not None:
root.set(key.strip("_"), str(value))
if isinstance(value, bool):
value = str(value).lower()
root.set(key, str(value))

def _to_etree_element(self) -> ET.Element:
"""Generate an ET.Element object from a Verb Object
Expand Down
2 changes: 1 addition & 1 deletion bandwidth/models/bxml/verbs/bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def _attributes(self):
"bridgeCompleteFallbackMethod": self.bridge_complete_fallback_method,
"bridgeTargetCompleteUrl": self.bridge_target_complete_url,
"bridgeTargetCompleteMethod": self.bridge_target_complete_method,
"bridgeTargetCompleteFallback_url": self.bridge_target_complete_fallback_url,
"bridgeTargetCompleteFallbackUrl": self.bridge_target_complete_fallback_url,
"bridgeTargetCompleteFallbackMethod": self.bridge_target_complete_fallback_method,
"username": self.username,
"password": self.password,
Expand Down
20 changes: 6 additions & 14 deletions bandwidth/models/bxml/verbs/conference.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
class Conference(Verb):

def __init__(
self, name: str, mute: str=None,
hold: str=None, call_ids_to_coach: str=None,
self, name: str, mute: bool=None,
hold: bool=None, call_ids_to_coach: str=None,
conference_event_url: str=None, conference_event_method: str=None,
conference_event_fallback_url: str=None, conference_event_fallback_method: str=None,
username: str=None, password: str=None,
Expand All @@ -23,8 +23,8 @@ def __init__(

Args:
name (str): The name of the conference. Can contain up to 100 characters of letters, numbers, and the symbols -, _, and .
mute (str, optional): A boolean value to indicate whether the member should be on mute in the conference. When muted, a member can hear others speak, but others cannot hear them speak. Defaults to false.
hold (str, optional): A boolean value to indicate whether the member should be on hold in the conference. When on hold, a member cannot hear others, and they cannot be heard. Defaults to false.
mute (bool, optional): A boolean value to indicate whether the member should be on mute in the conference. When muted, a member can hear others speak, but others cannot hear them speak. Defaults to false.
hold (bool, optional): A boolean value to indicate whether the member should be on hold in the conference. When on hold, a member cannot hear others, and they cannot be heard. Defaults to false.
call_ids_to_coach (str, optional): A comma-separated list of call ids to coach. When a call joins a conference with this attribute set, it will coach the listed calls.
Those calls will be able to hear and be heard by the coach, but other calls in the conference will not hear the coach.
conference_event_url (str, optional): URL to send Conference events to. The URL, method, username, and password are set by the BXML document that creates the conference,
Expand All @@ -41,14 +41,6 @@ def __init__(
Max length 256 characters. Defaults to None.
callback_timeout (str, optional): This is the timeout (in seconds) to use when delivering webhooks for the conference.
If not set, it will inherit the webhook timeout from the call that creates the conference. Can be any numeric value (including decimals) between 1 and 25.

Nested Verbs:
PlayAudio: (optional)
SpeakSentence: (optional)
StartRecording: (optional)
StopRecording: (optional)
PauseRecording: (optional)
ResumeRecording: (optional)
"""
self.name = name
self.mute = mute
Expand All @@ -65,13 +57,13 @@ def __init__(
self.tag = tag
self.callback_timeout = callback_timeout
super().__init__(
tag="Conference"
tag="Conference",
content=self.name,
)

@property
def _attributes(self):
return {
"name": self.name,
"mute": self.mute,
"hold": self.hold,
"callIdsToCoach": self.call_ids_to_coach,
Expand Down
8 changes: 6 additions & 2 deletions bandwidth/models/bxml/verbs/connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,19 @@ class Connect(NestableVerb):

def __init__(
self, destination: List[Endpoint] = [],
event_callback_url: str = None
event_callback_url: str = None,
event_fallback_url: str = None
):
"""Initialize a <Connect> verb

Args:
destination (list[Endpoint], optional): An Endpoint ID to connect the call to.
event_callback_url (str, optional): URL to send events to during the connection lifecycle. May be a relative URL. Defaults to None.
event_fallback_url (str, optional): A fallback url which, if provided, will be used to retry the event callback delivery in case event_callback_url fails to respond. Defaults to None.
"""
self.destination = destination
self.event_callback_url = event_callback_url
self.event_fallback_url = event_fallback_url

super().__init__(
tag="Connect",
Expand All @@ -34,5 +37,6 @@ def __init__(
@property
def _attributes(self):
return {
"eventCallbackUrl": self.event_callback_url
"eventCallbackUrl": self.event_callback_url,
"eventFallbackUrl": self.event_fallback_url
}
12 changes: 10 additions & 2 deletions bandwidth/models/bxml/verbs/forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ class Forward(Verb):
def __init__(
self, to: str=None, _from: str=None,
call_timeout: str=None, diversion_treatment: str=None,
diversion_reason: str=None, uui: str=None
diversion_reason: str=None, uui: str=None,
privacy: bool=None, caller_display_name: str=None
):
"""Initialize a <Forward> verb

Expand Down Expand Up @@ -45,21 +46,28 @@ def __init__(
uui (str, optional): The value of the User-To-User header to send within the outbound INVITE when forwarding to a SIP URI.
Must include the encoding parameter as specified in RFC 7433. Only base64 and jwt encoding are currently allowed.
This value, including the encoding specifier, may not exceed 256 characters.
privacy (bool, optional): A boolean value to indicate whether the calling number should be hidden. Use caller_display_name to customize the displayed name. Default is false.
caller_display_name (str, optional): The caller display name to use when the call is created. May not exceed 256 characters nor contain control characters such as new lines.
If privacy is true, only the values Restricted, Anonymous, Private, or Unavailable are valid.
"""
self.to = to
self._from = _from
self.call_timeout = call_timeout
self.diversion_treatment = diversion_treatment
self.diversion_reason = diversion_reason
self.uui = uui
self.privacy = privacy
self.caller_display_name = caller_display_name

super().__init__(tag="Forward")

@property
def _attributes(self):
return {
"to": self.to,
"_from": self._from,
"from": self._from,
"privacy": self.privacy,
"callerDisplayName": self.caller_display_name,
"callTimeout": self.call_timeout,
"diversionTreatment": self.diversion_treatment,
"diversionReason": self.diversion_reason,
Expand Down
30 changes: 29 additions & 1 deletion bandwidth/models/bxml/verbs/gather.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ def __init__(
fallback_username: str=None, fallback_password: str=None,
tag: str=None, terminating_digits: str=None,
max_digits: int=None, inter_digit_timeout: int=None,
first_digit_timeout: int=None, repeat_count: int=None
first_digit_timeout: int=None, repeat_count: int=None,
input: str=None, hints: str=None,
language: str=None, partial_result_callback: str=None,
partial_result_callback_method: str=None, profanity_filter: bool=None,
speech_model: str=None, speech_timeout: int=None
):
"""Initialize a <Gather> verb

Expand All @@ -43,6 +47,14 @@ def __init__(
Default value is 5. Range: decimal values between 0 - 60.
repeat_count (int, optional): The number of times the audio prompt should be played if no digits are pressed. For example, if this value is 3, the nested audio clip will be played a maximum of three times.
The delay between repetitions will be equal to first_digit_timeout. Default value is 1. repeat_count * number of verbs must not be greater than 20.
input (str, optional): The kind of input to collect: dtmf, speech, or dtmf_speech. Default value is dtmf.
hints (str, optional): Words or phrases that provide context to the speech recognition engine, improving accuracy for expected responses. Only used when input includes speech.
language (str, optional): The language code used for speech recognition, for example en-US. Only used when input includes speech.
partial_result_callback (str, optional): URL to send the Partial Result event to as speech is recognized. May be a relative URL. Only used when input includes speech.
partial_result_callback_method (str, optional): The HTTP method to use for the request to partial_result_callback. GET or POST. Default value is POST.
profanity_filter (bool, optional): A boolean value to indicate whether profane words are filtered out of the transcription. Default value is true. Only used when input includes speech.
speech_model (str, optional): The speech recognition model to use for transcribing the caller's speech. Only used when input includes speech.
speech_timeout (int, optional): Time (in seconds) to wait for speech input before terminating the Gather. Default value is 5. Only used when input includes speech.

Nested Verbs:
PlayAudio: (optional) Using the PlayAudio inside the Gather verb will play the media until a digit is received.
Expand All @@ -62,6 +74,14 @@ def __init__(
self.inter_digit_timeout = inter_digit_timeout
self.first_digit_timeout = first_digit_timeout
self.repeat_count = repeat_count
self.input = input
self.hints = hints
self.language = language
self.partial_result_callback = partial_result_callback
self.partial_result_callback_method = partial_result_callback_method
self.profanity_filter = profanity_filter
self.speech_model = speech_model
self.speech_timeout = speech_timeout
self.audio_verbs = audio_verbs
super().__init__(
tag="Gather",
Expand All @@ -84,4 +104,12 @@ def _attributes(self):
"interDigitTimeout": self.inter_digit_timeout,
"firstDigitTimeout": self.first_digit_timeout,
"repeatCount": self.repeat_count,
"input": self.input,
"hints": self.hints,
"language": self.language,
"partialResultCallback": self.partial_result_callback,
"partialResultCallbackMethod": self.partial_result_callback_method,
"profanityFilter": self.profanity_filter,
"speechModel": self.speech_model,
"speechTimeout": self.speech_timeout,
}
19 changes: 13 additions & 6 deletions bandwidth/models/bxml/verbs/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ def __init__(
record_complete_fallback_method: str=None,
recording_available_url: str=None,
recording_available_method: str=None,
transcribe: str=None, transcription_available_url: str=None,
transcribe: bool=None, transcription_available_url: str=None,
transcription_available_method: str=None, username: str=None,
password: str=None, fallback_username: str=None,
fallback_password: str=None, tag: str=None,
terminating_digits: str=None, max_duration: int=60,
silence_timeout: str=None, file_format: str=None
silence_timeout: str=None, file_format: str=None,
detect_language: bool=None, recording_name: str=None
):
"""Initialize a <Record> verb

Expand All @@ -33,7 +34,7 @@ def __init__(
record_complete_fallback_method (str, optional): The HTTP method to use to deliver the Record Complete callback to recordCompleteFallbackUrl. GET or POST. Default value is POST. Defaults to None.
recording_available_url (str, optional): URL to send the Recording Available event to once it has been processed. Does not accept BXML. May be a relative URL. Defaults to None.
recording_available_method (str, optional): The HTTP method to use for the request to recordingAvailableUrl. GET or POST. Default value is POST. Defaults to None.
transcribe (str, optional): A boolean value to indicate that recording should be transcribed. Transcription can succeed only for recordings of length greater than 500 milliseconds and less than 4 hours. Default is false. Defaults to None.
transcribe (bool, optional): A boolean value to indicate that recording should be transcribed. Transcription can succeed only for recordings of length greater than 500 milliseconds and less than 4 hours. Default is false. Defaults to None.
transcription_available_url (str, optional): URL to send the Transcription Available event to once it has been processed. Does not accept BXML. May be a relative URL. Defaults to None.
transcription_available_method (str, optional): The HTTP method to use for the request to transcriptionAvailableUrl. GET or POST. Default value is POST. Defaults to None.
username (str, optional): The username to send in the HTTP request to recordCompleteUrl, recordingAvailableUrl or transcriptionAvailableUrl. If specified, the URLs must be TLS-encrypted (i.e., https). Defaults to None.
Expand All @@ -45,6 +46,8 @@ def __init__(
max_duration (int, optional): Maximum length of recording (in seconds). Max 10800 (3 hours). Default value is 60. Defaults to None.
silence_timeout (str, optional): Length of silence after which to end the recording (in seconds). Max is equivalent to the maximum maxDuration value. Default value is 0, which means no timeout. Defaults to None.
file_format (str, optional): The audio format that the recording will be saved as: mp3 or wav. Default value is wav. Defaults to None.
detect_language (bool, optional): A boolean value to indicate that the transcription service should detect the dominant language spoken rather than assuming English. Ignored unless transcribe is true. Default is false. Defaults to None.
recording_name (str, optional): A name identifying this recording, returned in the Recording Available event. Defaults to None.
"""
self.record_complete_url = record_complete_url
self.record_complete_method = record_complete_method
Expand All @@ -64,6 +67,8 @@ def __init__(
self.max_duration = max_duration
self.silence_timeout = silence_timeout
self.file_format = file_format
self.detect_language = detect_language
self.recording_name = recording_name

super().__init__(tag="Record", content=None)

Expand All @@ -72,11 +77,12 @@ def _attributes(self):
return {
"recordCompleteUrl": self.record_complete_url,
"recordCompleteMethod": self.record_complete_method,
"recordCompleteFallback_url": self.record_complete_fallback_url,
"recordCompleteFallback_method": self.record_complete_fallback_method,
"recordCompleteFallbackUrl": self.record_complete_fallback_url,
"recordCompleteFallbackMethod": self.record_complete_fallback_method,
"recordingAvailableUrl": self.recording_available_url,
"recordingAvailableMethod": self.recording_available_method,
"transcribe": self.transcribe,
"detectLanguage": self.detect_language,
"transcriptionAvailableUrl": self.transcription_available_url,
"transcriptionAvailableMethod": self.transcription_available_method,
"username": self.username,
Expand All @@ -87,5 +93,6 @@ def _attributes(self):
"terminatingDigits": self.terminating_digits,
"maxDuration": self.max_duration,
"silenceTimeout": self.silence_timeout,
"fileFormat": self.file_format
"fileFormat": self.file_format,
"recordingName": self.recording_name
}
11 changes: 9 additions & 2 deletions bandwidth/models/bxml/verbs/start_recording.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ def __init__(
transcribe: bool = None, transcription_available_url: str = None,
transcription_available_method: str = None, username: str=None,
password: str=None, tag: str=None,
file_format: str = None, multi_channel: bool = None
file_format: str = None, multi_channel: bool = None,
detect_language: bool = None, recording_name: str = None
):
"""Initialize a <StartRecording> verb

Expand All @@ -31,6 +32,8 @@ def __init__(
tag (str, optional): A custom string that will be sent with this and all future callbacks unless overwritten by a future tag attribute or <Tag> verb, or cleared. May be cleared by setting tag="". Max length 256 characters. Defaults to None.
file_format (str, optional): The audio format that the recording will be saved as: mp3 or wav. Default value is wav. Defaults to None. max_duration (str, optional): Maximum length of recording (in seconds). Max 10800 (3 hours). Default value is 60. Defaults to None.
multi_channel (bool, optional): A boolean value indicating whether or not the recording file should separate each side of the call into its own audio channel. Default value is false.
detect_language (bool, optional): A boolean value to indicate that the transcription service should detect the dominant language spoken rather than assuming English. Ignored unless transcribe is true. Default is false. Defaults to None.
recording_name (str, optional): A name identifying this recording, returned in the Recording Available event. Defaults to None.

"""
self.recording_available_url = recording_available_url
Expand All @@ -43,6 +46,8 @@ def __init__(
self.tag = tag
self.file_format = file_format
self.multi_channel = multi_channel
self.detect_language = detect_language
self.recording_name = recording_name
super().__init__(tag="StartRecording")

@property
Expand All @@ -51,11 +56,13 @@ def _attributes(self):
"recordingAvailableUrl": self.recording_available_url,
"recordingAvailableMethod": self.recording_available_method,
"transcribe": self.transcribe,
"detectLanguage": self.detect_language,
"transcriptionAvailableUrl": self.transcription_available_url,
"transcriptionAvailableMethod": self.transcription_available_method,
"username": self.username,
"password": self.password,
"tag": self.tag,
"fileFormat": self.file_format,
"multiChannel": self.multi_channel
"multiChannel": self.multi_channel,
"recordingName": self.recording_name
}
Loading