diff --git a/bandwidth/models/bxml/verb.py b/bandwidth/models/bxml/verb.py index 128dcc0b..e100bdfe 100644 --- a/bandwidth/models/bxml/verb.py +++ b/bandwidth/models/bxml/verb.py @@ -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 diff --git a/bandwidth/models/bxml/verbs/bridge.py b/bandwidth/models/bxml/verbs/bridge.py index 515232e4..083d3671 100644 --- a/bandwidth/models/bxml/verbs/bridge.py +++ b/bandwidth/models/bxml/verbs/bridge.py @@ -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, diff --git a/bandwidth/models/bxml/verbs/conference.py b/bandwidth/models/bxml/verbs/conference.py index 5baba3f6..105c64af 100644 --- a/bandwidth/models/bxml/verbs/conference.py +++ b/bandwidth/models/bxml/verbs/conference.py @@ -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, @@ -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, @@ -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 @@ -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, diff --git a/bandwidth/models/bxml/verbs/connect.py b/bandwidth/models/bxml/verbs/connect.py index 876abfe6..c843f173 100644 --- a/bandwidth/models/bxml/verbs/connect.py +++ b/bandwidth/models/bxml/verbs/connect.py @@ -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 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", @@ -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 } diff --git a/bandwidth/models/bxml/verbs/forward.py b/bandwidth/models/bxml/verbs/forward.py index 364cb9ac..46feac36 100644 --- a/bandwidth/models/bxml/verbs/forward.py +++ b/bandwidth/models/bxml/verbs/forward.py @@ -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 verb @@ -45,6 +46,9 @@ 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 @@ -52,6 +56,8 @@ def __init__( 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") @@ -59,7 +65,9 @@ def __init__( 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, diff --git a/bandwidth/models/bxml/verbs/gather.py b/bandwidth/models/bxml/verbs/gather.py index d0a18a63..0f949139 100644 --- a/bandwidth/models/bxml/verbs/gather.py +++ b/bandwidth/models/bxml/verbs/gather.py @@ -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 verb @@ -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. @@ -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", @@ -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, } diff --git a/bandwidth/models/bxml/verbs/record.py b/bandwidth/models/bxml/verbs/record.py index 55ebd871..4288037f 100644 --- a/bandwidth/models/bxml/verbs/record.py +++ b/bandwidth/models/bxml/verbs/record.py @@ -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 verb @@ -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. @@ -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 @@ -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) @@ -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, @@ -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 } diff --git a/bandwidth/models/bxml/verbs/start_recording.py b/bandwidth/models/bxml/verbs/start_recording.py index 695f4ad9..e8714476 100644 --- a/bandwidth/models/bxml/verbs/start_recording.py +++ b/bandwidth/models/bxml/verbs/start_recording.py @@ -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 verb @@ -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 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 @@ -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 @@ -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 } diff --git a/bandwidth/models/bxml/verbs/start_transcription.py b/bandwidth/models/bxml/verbs/start_transcription.py index c3f10f0d..1891d93f 100644 --- a/bandwidth/models/bxml/verbs/start_transcription.py +++ b/bandwidth/models/bxml/verbs/start_transcription.py @@ -22,6 +22,8 @@ def __init__( destination: str = None, stabilized: bool = None, custom_params: List[CustomParam] = None, + detect_language: bool = None, + preferred_languages: str = None, ): """ Initialize a verb @@ -32,8 +34,10 @@ def __init__( :param username: The username to send in the HTTP request to transcriptionEventUrl. If specified, the transcriptionEventUrl must be TLS-encrypted (i.e., https). :param password: The password to send in the HTTP request to transcriptionEventUrl. If specified, the transcriptionEventUrl must be TLS-encrypted (i.e., https). :param destination: A websocket URI to send the transcription to. A transcription of the specified tracks will be sent via websocket to this URL as a series of JSON messages. See below for more details on the websocket packet format. - :param stabilized: A websocket URI to send the transcription to. A transcription of the specified tracks will be sent via websocket to this URL as a series of JSON messages. See below for more details on the websocket packet format. + :param stabilized: A boolean value to indicate whether only stable transcription updates are sent, rather than interim results that may be revised. Requires destination to be set. Default is true. :param custom_params: These elements define optional user specified parameters that will be sent to the destination URL when the real-time transcription is first started. + :param detect_language: A boolean value to indicate that the transcription service should detect the dominant language spoken rather than assuming English. Default is false. + :param preferred_languages: A comma-separated list of language locales to transcribe in, for example en-US,es-US. Defaults to en-US. Requires detect_language to be false. Only one dialect per language is allowed. """ self.name = name self.tracks = tracks @@ -44,6 +48,8 @@ def __init__( self.destination = destination self.stabilized = stabilized self.custom_params = custom_params + self.detect_language = detect_language + self.preferred_languages = preferred_languages super().__init__( tag="StartTranscription", @@ -61,4 +67,6 @@ def _attributes(self): "password": self.password, "destination": self.destination, "stabilized": self.stabilized, + "detectLanguage": self.detect_language, + "preferredLanguages": self.preferred_languages, } diff --git a/bandwidth/models/bxml/verbs/transfer.py b/bandwidth/models/bxml/verbs/transfer.py index 24959523..d5de1997 100644 --- a/bandwidth/models/bxml/verbs/transfer.py +++ b/bandwidth/models/bxml/verbs/transfer.py @@ -22,7 +22,8 @@ def __init__( transfer_complete_fallback_method: str=None, username: str=None, password: str=None, fallback_username: str=None, fallback_password: str=None, tag: str=None, - diversion_treatment: str=None, diversion_reason: str=None + diversion_treatment: str=None, diversion_reason: str=None, + privacy: bool=None ): """Initialize a verb @@ -61,6 +62,7 @@ def __init__( This parameter is considered only when diversionTreatment is set to stack. Defaults is unknown. Defaults to None. + privacy (bool, optional): A boolean value to indicate whether the calling number should be hidden. Use transfer_caller_display_name to customize the displayed name. Default is false. """ self.transfer_to = transfer_to self.transfer_caller_id = transfer_caller_id @@ -77,6 +79,7 @@ def __init__( self.tag = tag self.diversion_treatment = diversion_treatment self.diversion_reason = diversion_reason + self.privacy = privacy super().__init__( tag="Transfer", nested_verbs=self.transfer_to @@ -86,6 +89,7 @@ def __init__( def _attributes(self): return { "transferCallerId": self.transfer_caller_id, + "privacy": self.privacy, "transferCallerDisplayName": self.transfer_caller_display_name, "callTimeout": self.call_timeout, "transferCompleteUrl": self.transfer_complete_url, diff --git a/test/unit/models/bxml/test_bridge.py b/test/unit/models/bxml/test_bridge.py index 2435c2e7..bdc756de 100644 --- a/test/unit/models/bxml/test_bridge.py +++ b/test/unit/models/bxml/test_bridge.py @@ -15,8 +15,19 @@ class TestBridge(unittest.TestCase): def setUp(self): self.bridge = Bridge( target_call="+19198675309", - bridge_complete_url="https://example.com", - tag="test" + bridge_complete_url="example.com/completeurl", + bridge_complete_method="POST", + bridge_complete_fallback_url="backupexample.com/completeurl", + bridge_complete_fallback_method="POST", + bridge_target_complete_url="example.com/targetcompleteurl", + bridge_target_complete_method="POST", + bridge_target_complete_fallback_url="backupexample.com/targetcompleteurl", + bridge_target_complete_fallback_method="POST", + username="user", + password="pass", + fallback_username="user", + fallback_password="pass", + tag="tag" ) def test_instance(self): @@ -24,5 +35,5 @@ def test_instance(self): assert isinstance(self.bridge, Verb) def test_to_bxml(self): - expected = '+19198675309' + expected = '+19198675309' assert expected == self.bridge.to_bxml() diff --git a/test/unit/models/bxml/test_conference.py b/test/unit/models/bxml/test_conference.py index 059b4a4f..9ac2ab77 100644 --- a/test/unit/models/bxml/test_conference.py +++ b/test/unit/models/bxml/test_conference.py @@ -15,8 +15,8 @@ class TestConference(unittest.TestCase): def setUp(self): self.conference = Conference( name="conf1", - mute = "true", - hold = "false", + mute = True, + hold = False, call_ids_to_coach = "example-call-id", conference_event_url = "example.com/eventurl", conference_event_method = "POST", @@ -35,5 +35,5 @@ def test_instance(self): assert isinstance(self.conference, Verb) def test_to_bxml(self): - expected = '' + expected = 'conf1' assert expected == self.conference.to_bxml() diff --git a/test/unit/models/bxml/test_connect.py b/test/unit/models/bxml/test_connect.py index 37e88214..83de0503 100644 --- a/test/unit/models/bxml/test_connect.py +++ b/test/unit/models/bxml/test_connect.py @@ -19,6 +19,7 @@ def setUp(self): self.connect = Connect( event_callback_url= "https://callback-test.com", + event_fallback_url= "https://fallback-test.com", destination=[self.endpoint] ) @@ -35,7 +36,7 @@ def test_defaults(self): assert expected == connect.to_bxml() def test_to_bxml(self): - expected = 'endpoint-id' + expected = 'endpoint-id' assert expected == self.connect.to_bxml() def test_add_verb(self): diff --git a/test/unit/models/bxml/test_forward.py b/test/unit/models/bxml/test_forward.py index 66e9ec96..55177cb2 100644 --- a/test/unit/models/bxml/test_forward.py +++ b/test/unit/models/bxml/test_forward.py @@ -18,7 +18,9 @@ def setUp(self): call_timeout = "15", diversion_treatment="propagate", diversion_reason="away", - uui="93d6f3c0be5845960b744fa28015d8ede84bd1a4;encoding=base64,asdf;encoding=jwt" + uui="93d6f3c0be5845960b744fa28015d8ede84bd1a4;encoding=base64,asdf;encoding=jwt", + privacy=True, + caller_display_name="Restricted" ) def test_instance(self): @@ -26,5 +28,5 @@ def test_instance(self): assert isinstance(self.forward, Verb) def test_to_bxml(self): - expected = '' + expected = '' assert expected == self.forward.to_bxml() diff --git a/test/unit/models/bxml/test_gather.py b/test/unit/models/bxml/test_gather.py index 3993ec6b..41c37cdc 100644 --- a/test/unit/models/bxml/test_gather.py +++ b/test/unit/models/bxml/test_gather.py @@ -38,6 +38,14 @@ def setUp(self): inter_digit_timeout = 1, first_digit_timeout = 3, repeat_count = 2, + input = "dtmf_speech", + hints = "yes,no", + language = "en-US", + partial_result_callback = "partial-test.com", + partial_result_callback_method = "POST", + profanity_filter = True, + speech_model = "default", + speech_timeout = 4, audio_verbs=[self.play_audio] ) @@ -54,10 +62,10 @@ def test_defaults(self): assert expected == gather.to_bxml() def test_to_bxml(self): - expected = 'https://audio.url/audio1.wav' + expected = 'https://audio.url/audio1.wav' assert expected == self.gather.to_bxml() def test_add_verb(self): - expected = 'https://audio.url/audio1.wavHello. Your number is asdf, lets play a game. What is 10 + 3. Press the pound key when finished.' + expected = 'https://audio.url/audio1.wavHello. Your number is asdf, lets play a game. What is 10 + 3. Press the pound key when finished.' self.gather.add_verb(self.speak_sentence) assert expected == self.gather.to_bxml() diff --git a/test/unit/models/bxml/test_phone_number.py b/test/unit/models/bxml/test_phone_number.py index 28561115..74eb545a 100644 --- a/test/unit/models/bxml/test_phone_number.py +++ b/test/unit/models/bxml/test_phone_number.py @@ -18,6 +18,14 @@ def setUp(self): uui="abc123", transfer_answer_url="https://example.com/webhooks/transfer_answer", transfer_answer_method="POST", + transfer_answer_fallback_url="https://fallback.example.com/webhooks/transfer_answer", + transfer_answer_fallback_method="GET", + transfer_disconnect_url="https://example.com/webhooks/transfer_disconnect", + transfer_disconnect_method="POST", + username="user", + password="pass", + fallback_username="fallbackUser", + fallback_password="fallbackPass", tag="" ) @@ -26,5 +34,5 @@ def test_instance(self): assert isinstance(self.phone_number, Verb) def test_to_bxml(self): - expected = '+19195551234' + expected = '+19195551234' assert expected == self.phone_number.to_bxml() diff --git a/test/unit/models/bxml/test_record.py b/test/unit/models/bxml/test_record.py index d7b350ea..a295a078 100644 --- a/test/unit/models/bxml/test_record.py +++ b/test/unit/models/bxml/test_record.py @@ -13,13 +13,33 @@ class TestRecord(unittest.TestCase): def setUp(self): - self.record = Record() - self.record.max_duration = 10 + self.record = Record( + record_complete_url="example.com/completeurl", + record_complete_method="POST", + record_complete_fallback_url="backupexample.com/completeurl", + record_complete_fallback_method="POST", + recording_available_url="example.com/availableurl", + recording_available_method="POST", + transcribe=True, + transcription_available_url="example.com/transcriptionurl", + transcription_available_method="POST", + username="user", + password="pass", + fallback_username="user", + fallback_password="pass", + tag="tag", + terminating_digits="#", + max_duration=10, + silence_timeout="5", + file_format="wav", + detect_language=True, + recording_name="recording1" + ) def test_instance(self): assert isinstance(self.record, Record) assert isinstance(self.record, Verb) def test_to_bxml(self): - expected = '' + expected = '' assert expected == self.record.to_bxml() diff --git a/test/unit/models/bxml/test_redirect.py b/test/unit/models/bxml/test_redirect.py index c836c3f7..c693e9ef 100644 --- a/test/unit/models/bxml/test_redirect.py +++ b/test/unit/models/bxml/test_redirect.py @@ -13,12 +13,22 @@ class TestRedirect(unittest.TestCase): def setUp(self): - self.redirect = Redirect("https://example.com/redirect") + self.redirect = Redirect( + redirect_url="https://example.com/redirect", + redirect_method="POST", + redirect_fallback_url="https://fallback.example.com/redirect", + redirect_fallback_method="GET", + username="user", + password="pass", + fallback_username="fallbackUser", + fallback_password="fallbackPass", + tag="tag" + ) def test_instance(self): assert isinstance(self.redirect, Redirect) assert isinstance(self.redirect, Verb) def test_to_bxml(self): - expected = '' + expected = '' assert expected == self.redirect.to_bxml() diff --git a/test/unit/models/bxml/test_ring.py b/test/unit/models/bxml/test_ring.py index 14df46eb..cdb3c931 100644 --- a/test/unit/models/bxml/test_ring.py +++ b/test/unit/models/bxml/test_ring.py @@ -23,5 +23,5 @@ def test_instance(self): assert isinstance(self.ring, Verb) def test_to_bxml(self): - expected = '' + expected = '' assert expected == self.ring.to_bxml() diff --git a/test/unit/models/bxml/test_sip_uri.py b/test/unit/models/bxml/test_sip_uri.py index c8abb464..bba09110 100644 --- a/test/unit/models/bxml/test_sip_uri.py +++ b/test/unit/models/bxml/test_sip_uri.py @@ -18,6 +18,14 @@ def setUp(self): uui="abc123", transfer_answer_url="https://example.com/webhooks/transfer_answer", transfer_answer_method="POST", + transfer_answer_fallback_url="https://fallback.example.com/webhooks/transfer_answer", + transfer_answer_fallback_method="GET", + transfer_disconnect_url="https://example.com/webhooks/transfer_disconnect", + transfer_disconnect_method="POST", + username="user", + password="pass", + fallback_username="fallbackUser", + fallback_password="fallbackPass", tag="test" ) @@ -26,5 +34,5 @@ def test_instance(self): assert isinstance(self.sip_uri, Verb) def test_to_bxml(self): - expected = 'sip:1-999-123-4567@voip-provider.example.net' + expected = 'sip:1-999-123-4567@voip-provider.example.net' assert expected == self.sip_uri.to_bxml() diff --git a/test/unit/models/bxml/test_speak_sentence.py b/test/unit/models/bxml/test_speak_sentence.py index 6d9b1d8f..46cafb18 100644 --- a/test/unit/models/bxml/test_speak_sentence.py +++ b/test/unit/models/bxml/test_speak_sentence.py @@ -15,7 +15,9 @@ class TestSpeakSentence(unittest.TestCase): def setUp(self): self.speak_sentence = SpeakSentence( text='Hello. Your number is asdf, lets play a game. What is 10 + 3. Press the pound key when finished.', - voice="julie" + voice="julie", + gender="female", + locale="en_US" ) def test_instance(self): @@ -23,11 +25,11 @@ def test_instance(self): assert isinstance(self.speak_sentence, Verb) def test_to_bxml(self): - expected = 'Hello. Your number is asdf, lets play a game. What is 10 + 3. Press the pound key when finished.' + expected = 'Hello. Your number is asdf, lets play a game. What is 10 + 3. Press the pound key when finished.' assert expected == self.speak_sentence.to_bxml() def test_to_bxml_within_response(self): - expected = '\nHello. Your number is asdf, lets play a game. What is 10 + 3. Press the pound key when finished.' + expected = '\nHello. Your number is asdf, lets play a game. What is 10 + 3. Press the pound key when finished.' response = Response() response.add_verb(self.speak_sentence) assert expected == response.to_bxml() diff --git a/test/unit/models/bxml/test_start_recording.py b/test/unit/models/bxml/test_start_recording.py index bb459701..44a7a06d 100644 --- a/test/unit/models/bxml/test_start_recording.py +++ b/test/unit/models/bxml/test_start_recording.py @@ -23,7 +23,9 @@ def setUp(self): password = "pass", tag = "tag", file_format = "wav", - multi_channel = True + multi_channel = True, + detect_language = True, + recording_name = "recording1" ) def test_instance(self): @@ -31,5 +33,5 @@ def test_instance(self): assert isinstance(self.start_recording, Verb) def test_to_bxml(self): - expected = '' + expected = '' assert expected == self.start_recording.to_bxml() diff --git a/test/unit/models/bxml/test_start_transcription.py b/test/unit/models/bxml/test_start_transcription.py index 61861c52..9abcb5bb 100644 --- a/test/unit/models/bxml/test_start_transcription.py +++ b/test/unit/models/bxml/test_start_transcription.py @@ -31,7 +31,9 @@ def setUp(self) -> None: password="pass", destination="testurl.com", stabilized=True, - custom_params=[self.custom_param1] + custom_params=[self.custom_param1], + detect_language=True, + preferred_languages="en-US,es-US" ) def test_instance(self): @@ -40,10 +42,10 @@ def test_instance(self): assert isinstance(self.start_transcription, Verb) def test_to_bxml(self): - expected = '' + expected = '' assert expected == self.start_transcription.to_bxml() def test_add_verb(self): - expected = '' + expected = '' self.start_transcription.add_verb(self.custom_param2) assert expected == self.start_transcription.to_bxml() diff --git a/test/unit/models/bxml/test_stop_stream.py b/test/unit/models/bxml/test_stop_stream.py index 09df28ce..7c82bee1 100644 --- a/test/unit/models/bxml/test_stop_stream.py +++ b/test/unit/models/bxml/test_stop_stream.py @@ -20,5 +20,5 @@ def test_instance(self): assert isinstance(self.stop_stream, Verb) def test_to_bxml(self): - expected = '' + expected = '' assert expected == self.stop_stream.to_bxml() diff --git a/test/unit/models/bxml/test_transfer.py b/test/unit/models/bxml/test_transfer.py index 6e667835..09f6fbaf 100644 --- a/test/unit/models/bxml/test_transfer.py +++ b/test/unit/models/bxml/test_transfer.py @@ -26,7 +26,18 @@ def setUp(self): call_timeout = "15", transfer_caller_id = "+19195554321", transfer_caller_display_name="test", - tag = "test" + tag = "test", + privacy=True, + transfer_complete_url="https://example.com/transfer_complete", + transfer_complete_method="POST", + transfer_complete_fallback_url="https://fallback.example.com/transfer_complete", + transfer_complete_fallback_method="GET", + username="user", + password="pass", + fallback_username="fallbackUser", + fallback_password="fallbackPass", + diversion_treatment="propagate", + diversion_reason="away" ) def test_instance(self): @@ -35,10 +46,10 @@ def test_instance(self): assert isinstance(self.transfer, Verb) def test_to_bxml(self): - expected = 'sip@bw.com' + expected = 'sip@bw.com' assert expected == self.transfer.to_bxml() def test_add_verb(self): - expected = 'sip@bw.com+19195551234' + expected = 'sip@bw.com+19195551234' self.transfer.add_transfer_recipient(self.phone_number) assert expected == self.transfer.to_bxml()