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
1 change: 1 addition & 0 deletions bandwidth/model/bxml/verbs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
61 changes: 61 additions & 0 deletions bandwidth/model/bxml/verbs/start_recording.py
Original file line number Diff line number Diff line change
@@ -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 <StartRecording> 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 <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 (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
}
45 changes: 45 additions & 0 deletions test/unit/bxml/test_start_recording.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
"""
test_start_recording.py

Unit tests for the <StartRecording> 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 = '<StartRecording fileFormat="wav" multiChannel="true" password="pass" recordingAvailableMethod="POST" recordingAvailableUrl="example.com" tag="tag" transcribe="true" transcriptionAvailableMethod="POST" transcriptionAvailableUrl="transcription-example.com" username="user" />'
else:
expected = '<StartRecording recordingAvailableUrl="example.com" recordingAvailableMethod="POST" transcribe="true" transcriptionAvailableUrl="transcription-example.com" transcriptionAvailableMethod="POST" username="user" password="pass" tag="tag" fileFormat="wav" multiChannel="true" />'

assert(expected == self.start_recording.to_bxml())


def test_add_verb(self):
with pytest.raises(AttributeError):
self.start_recording.add_verb(self.test_verb)