diff --git a/bandwidth/model/bxml/verbs/forward.py b/bandwidth/model/bxml/verbs/forward.py new file mode 100644 index 00000000..7e6ff6f2 --- /dev/null +++ b/bandwidth/model/bxml/verbs/forward.py @@ -0,0 +1,66 @@ +""" +forward.py + +Bandwidth's Forward BXML verb + +@copyright Bandwidth INC +""" +from ..terminal_verb import TerminalVerb + + +class Forward(TerminalVerb): + + def __init__( + self, to: str=None, from_: str=None, + call_timeout: str=None, diversion_treatment: str=None, + diversion_reason: str=None, uui: str=None + ): + """Initialize a verb + + Args: + to (str): The phone number destination of the call. + from_ (str, optional): The phone number that the recipient will receive the call from. + call_timeout (str, optional): The number of seconds to wait before timing out the call. + diversion_treatment (str, optional): Can be any of the following: + none: No diversion headers are sent on the outbound leg of the transferred call. + propagate: Copy the Diversion header from the inbound leg to the outbound leg. Ignored if there is no Diversion header present on the inbound leg. + stack: After propagating any Diversion header from the inbound leg to the outbound leg, stack on top another Diversion header based on the Request-URI of the inbound call. + + Defaults to none. If diversionTreatment is not specified, no diversion header will be included for the transfer even if one came with the inbound call. Defaults to None. + diversion_reason (str, optional): Can be any of the following values: + unknown + user-busy + no-answer + unavailable + unconditional + time-of-day + do-not-disturb + deflection + follow-me + out-of-service + away + + This parameter is considered only when diversionTreatment is set to stack. Defaults is unknown. + Defaults to None. + uui (str, optional): The value of the User-To-User header to send within the outbound INVITE when forwarding to a SIP URI. + Must include the encoding parameter as specified in RFC 7433. Only base64 and jwt encoding are currently allowed. + This value, including the encoding specifier, may not exceed 256 characters. + """ + self.to = to + self.from_ = from_ + self.call_timeout = call_timeout + self.diversion_treatment = diversion_treatment + self.diversion_reason = diversion_reason + self.uui = uui + + super().__init__(tag="Forward", content=None) + @property + def _attributes(self): + return { + "to": self.to, + "from_": self.from_, + "callTimeout": self.call_timeout, + "diversionTreatment": self.diversion_treatment, + "diversionReason": self.diversion_reason, + "uui": self.uui, + } diff --git a/test/unit/bxml/test_forward.py b/test/unit/bxml/test_forward.py new file mode 100644 index 00000000..b6409e1f --- /dev/null +++ b/test/unit/bxml/test_forward.py @@ -0,0 +1,38 @@ +""" +test_forward.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.forward import Forward + +class TestForward(unittest.TestCase): + + def setUp(self): + self.forward = Forward( + to="19195554321", + from_="19195554322", + call_timeout = "15", + diversion_treatment="propagate", + diversion_reason="away", + uui="93d6f3c0be5845960b744fa28015d8ede84bd1a4;encoding=base64,asdf;encoding=jwt" + ) + self.test_verb = Verb(tag="test") + + + def test_to_bxml(self): + if os.environ['PYTHON_VERSION'] == '3.7': + expected = '' + else: + expected = '' + assert(expected == self.forward.to_bxml()) + + def test_add_verb(self): + with pytest.raises(AttributeError): + self.forward.add_verb(self.test_verb)