diff --git a/bandwidth/model/bxml/verbs/__init__.py b/bandwidth/model/bxml/verbs/__init__.py index d4fd28c1..dc2a1c68 100644 --- a/bandwidth/model/bxml/verbs/__init__.py +++ b/bandwidth/model/bxml/verbs/__init__.py @@ -3,6 +3,7 @@ from .phone_number import PhoneNumber from .play_audio import PlayAudio from .record import Record +from .start_recording import StartRecording from .sip_uri import SipUri from .speak_sentence import SpeakSentence from .tag import Tag diff --git a/bandwidth/model/bxml/verbs/start_recording.py b/bandwidth/model/bxml/verbs/start_recording.py new file mode 100644 index 00000000..27dd03fb --- /dev/null +++ b/bandwidth/model/bxml/verbs/start_recording.py @@ -0,0 +1,61 @@ +""" +start_recording.py + +Bandwidth's StartRecording BXML verb + +@copyright Bandwidth INC +""" +from ..terminal_verb import TerminalVerb + + +class StartRecording(TerminalVerb): + + def __init__( + self, recording_available_url: str = None, + recording_available_method: str = None, + transcribe: str = 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: str = None + ): + """Initialize a verb + + Args: + 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. + 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. + 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. + password (str, optional): The password 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. + 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 (str, 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. + + """ + self.recording_available_url = recording_available_url + self.recording_available_method = recording_available_method + self.transcribe = transcribe + self.transcription_available_url = transcription_available_url + self.transcription_available_method = transcription_available_method + self.username = username + self.password = password + self.tag = tag + self.file_format = file_format + self.multi_channel = multi_channel + super().__init__(tag="StartRecording", content=None) + + @property + def _attributes(self): + return { + "recordingAvailableUrl": self.recording_available_url, + "recordingAvailableMethod": self.recording_available_method, + "transcribe": self.transcribe, + "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 + } diff --git a/test/unit/bxml/test_start_recording.py b/test/unit/bxml/test_start_recording.py new file mode 100644 index 00000000..d1b40c91 --- /dev/null +++ b/test/unit/bxml/test_start_recording.py @@ -0,0 +1,45 @@ +""" +test_start_recording.py + +Unit tests for the BXML verb + +@copyright Bandwidth Inc. +""" +import os +import pytest +import unittest + +from bandwidth.model.bxml.verb import Verb +from bandwidth.model.bxml.verbs.start_recording import StartRecording + + +class TestRecord(unittest.TestCase): + + def setUp(self): + self.start_recording = StartRecording( + recording_available_url = "example.com", + recording_available_method = "POST", + transcribe = "true", + transcription_available_url = "transcription-example.com", + transcription_available_method = "POST", + username = "user", + password = "pass", + tag = "tag", + file_format = "wav", + multi_channel = "true" + ) + self.test_verb = Verb(tag="test") + + + def test_to_bxml(self): + if os.environ['PYTHON_VERSION'] == '3.7': + expected = '' + else: + expected = '' + + assert(expected == self.start_recording.to_bxml()) + + + def test_add_verb(self): + with pytest.raises(AttributeError): + self.start_recording.add_verb(self.test_verb)