diff --git a/bandwidth/model/bxml/verbs/__init__.py b/bandwidth/model/bxml/verbs/__init__.py index 8d6e0dc1..3cd4b97a 100644 --- a/bandwidth/model/bxml/verbs/__init__.py +++ b/bandwidth/model/bxml/verbs/__init__.py @@ -9,6 +9,7 @@ from .send_dtmf import SendDtmf from .sip_uri import SipUri from .speak_sentence import SpeakSentence +from .start_gather import StartGather from .start_recording import StartRecording from .start_stream import StartStream from .stop_gather import StopGather diff --git a/bandwidth/model/bxml/verbs/start_gather.py b/bandwidth/model/bxml/verbs/start_gather.py new file mode 100644 index 00000000..560e4c78 --- /dev/null +++ b/bandwidth/model/bxml/verbs/start_gather.py @@ -0,0 +1,43 @@ +""" +start_gather.py + +Bandwidth's StartGather BXML verb + +@copyright Bandwidth INC +""" +from ..terminal_verb import TerminalVerb + + +class StartGather(TerminalVerb): + + def __init__( + self, dtmf_url: str, dtmf_method: str=None, username: str=None, + password: str=None, tag: str=None, + ): + """Initialize a verb + + Args: + dtmf_url (str): URL to send the DTMF event to. May be a relative URL.. + dtmf_method (str, optional): The HTTP method to use for the request to dtmfUrl. GET or POST. Default value is POST. Defaults to None. + username (str, optional): The username to send in the HTTP request to dtmfUrl. Defaults to None. + password (str, optional): The password to send in the HTTP request to dtmfUrl. Defaults to None. + tag (str, optional): A custom string that will be sent with these and all future callbacks unless overwritten by a future tag attribute or cleared. May be cleared by setting tag="" Max length 256 characters. Defaults to None. + """ + self.dtmf_url = dtmf_url + self.dtmf_method = dtmf_method + self.username = username + self.password = password + self.tag = tag + super().__init__( + tag="StartGather" + ) + + @property + def _attributes(self): + return { + "dtmfUrl": self.dtmf_url, + "dtmfMethod": self.dtmf_method, + "username": self.username, + "password": self.password, + "tag": self.tag + } diff --git a/test/unit/bxml/test_start_gather.py b/test/unit/bxml/test_start_gather.py new file mode 100644 index 00000000..7600c3ad --- /dev/null +++ b/test/unit/bxml/test_start_gather.py @@ -0,0 +1,38 @@ +""" +test_start_gather.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_gather import StartGather + + +class TestPhoneNumber(unittest.TestCase): + + def setUp(self): + self.start_gather = StartGather( + dtmf_url="https://example.com/startgather", + dtmf_method="POST", + username="user", + password="pass", + tag="tag" + ) + 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_gather.to_bxml()) + + def test_add_verb(self): + with pytest.raises(AttributeError): + self.start_gather.add_verb(self.test_verb)