From efea798b245e9e6a81a2646bffc71a78c99b3d59 Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 4 Oct 2022 14:09:50 -0400 Subject: [PATCH 1/2] DX-2910 --- bandwidth/model/bxml/verbs/__init__.py | 1 + bandwidth/model/bxml/verbs/pause_recording.py | 2 +- bandwidth/model/bxml/verbs/start_gather.py | 44 +++++++++++++++++++ test/unit/bxml/test_start_gather.py | 38 ++++++++++++++++ 4 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 bandwidth/model/bxml/verbs/start_gather.py create mode 100644 test/unit/bxml/test_start_gather.py diff --git a/bandwidth/model/bxml/verbs/__init__.py b/bandwidth/model/bxml/verbs/__init__.py index c29ce144..b884c998 100644 --- a/bandwidth/model/bxml/verbs/__init__.py +++ b/bandwidth/model/bxml/verbs/__init__.py @@ -3,5 +3,6 @@ from .phone_number import PhoneNumber from .record import Record from .sip_uri import SipUri +from .start_gather import StartGather from .tag import Tag from .transfer import Transfer diff --git a/bandwidth/model/bxml/verbs/pause_recording.py b/bandwidth/model/bxml/verbs/pause_recording.py index dffc73ab..e18e8314 100644 --- a/bandwidth/model/bxml/verbs/pause_recording.py +++ b/bandwidth/model/bxml/verbs/pause_recording.py @@ -13,4 +13,4 @@ class PauseRecording(TerminalVerb): def __init__(self): """Initialize a verb """ - super().__init__(tag="PauseRecording", content=None, attributes=None) + super().__init__(tag="PauseRecording", content=None) diff --git a/bandwidth/model/bxml/verbs/start_gather.py b/bandwidth/model/bxml/verbs/start_gather.py new file mode 100644 index 00000000..54c785dd --- /dev/null +++ b/bandwidth/model/bxml/verbs/start_gather.py @@ -0,0 +1,44 @@ +""" +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", + content=None + ) + + @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) From f14d1584edead7288669209d75f316f4b2ad5ce3 Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 5 Oct 2022 09:26:47 -0400 Subject: [PATCH 2/2] Quick updates --- bandwidth/model/bxml/verbs/pause_recording.py | 2 +- bandwidth/model/bxml/verbs/start_gather.py | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/bandwidth/model/bxml/verbs/pause_recording.py b/bandwidth/model/bxml/verbs/pause_recording.py index e18e8314..b7a7de5e 100644 --- a/bandwidth/model/bxml/verbs/pause_recording.py +++ b/bandwidth/model/bxml/verbs/pause_recording.py @@ -13,4 +13,4 @@ class PauseRecording(TerminalVerb): def __init__(self): """Initialize a verb """ - super().__init__(tag="PauseRecording", content=None) + super().__init__(tag="PauseRecording") diff --git a/bandwidth/model/bxml/verbs/start_gather.py b/bandwidth/model/bxml/verbs/start_gather.py index 54c785dd..560e4c78 100644 --- a/bandwidth/model/bxml/verbs/start_gather.py +++ b/bandwidth/model/bxml/verbs/start_gather.py @@ -29,8 +29,7 @@ def __init__( self.password = password self.tag = tag super().__init__( - tag="StartGather", - content=None + tag="StartGather" ) @property