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 @@ -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
Expand Down
43 changes: 43 additions & 0 deletions bandwidth/model/bxml/verbs/start_gather.py
Original file line number Diff line number Diff line change
@@ -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 <StartGather> 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
}
38 changes: 38 additions & 0 deletions test/unit/bxml/test_start_gather.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"""
test_start_gather.py

Unit tests for the <StartGather> 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 = '<StartGather dtmfMethod="POST" dtmfUrl="https://example.com/startgather" password="pass" tag="tag" username="user" />'
else:
expected = '<StartGather dtmfUrl="https://example.com/startgather" dtmfMethod="POST" username="user" password="pass" tag="tag" />'

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

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