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 @@ -7,6 +7,7 @@
from .phone_number import PhoneNumber
from .play_audio import PlayAudio
from .record import Record
from .redirect import Redirect
from .ring import Ring
from .send_dtmf import SendDtmf
from .sip_uri import SipUri
Expand Down
32 changes: 18 additions & 14 deletions bandwidth/model/bxml/verbs/bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,24 @@ def __init__(
"""Initialize a <Bridge> verb

Args:
target_call (str): _description_
bridge_complete_url (str, optional): _description_. Defaults to None.
bridge_complete_method (str, optional): _description_. Defaults to None.
bridge_complete_fallback_url (str, optional): _description_. Defaults to None.
bridge_complete_fallback_method (str, optional): _description_. Defaults to None.
bridge_target_complete_url (str, optional): _description_. Defaults to None.
bridge_target_complete_method (str, optional): _description_. Defaults to None.
bridge_target_complete_fallback_url (str, optional): _description_. Defaults to None.
bridge_target_complete_fallback_method (str, optional): _description_. Defaults to None.
username (str, optional): _description_. Defaults to None.
password (str, optional): _description_. Defaults to None.
fallback_username (str, optional): _description_. Defaults to None.
fallback_password (str, optional): _description_. Defaults to None.
tag (str, optional): _description_. Defaults to None.
target_call (str): String containing the callId of the call to be bridged.
bridge_complete_url (str, optional): URL to send the Bridge Complete event to and request new BXML.
If this attribute is specified, then Verbs following the <Bridge> verb will be ignored and the BXML returned in this webhook is executed on the call.
If this attribute is not specified then no webhook will be sent, and execution of the verbs following the <Bridge> verb continues. May be a relative URL. Defaults to None.
bridge_complete_method (str, optional): The HTTP method to use for the request to bridgeCompleteUrl. GET or POST. Default value is POST.
bridge_complete_fallback_url (str, optional): A fallback url which, if provided, will be used to retry the Bridge Complete webhook delivery in case bridgeCompleteUrl fails to respond. Defaults to None.
bridge_complete_fallback_method (str, optional): The HTTP method to use to deliver the Bridge Complete webhook to bridgeCompleteFallbackUrl. GET or POST. Default value is POST.
bridge_target_complete_url (str, optional):URL to send the Bridge Target Complete event to and request new BXML.
If this attribute is specified, then the BXML returned in this webhook is executed on the target call.
If this attribute is not specified then no webhook will be sent, and the target call will be hung up. May be a relative URL. Defaults to None.
bridge_target_complete_method (str, optional): The HTTP method to use for the request to bridgeTargetCompleteUrl. GET or POST. Default value is POST.
bridge_target_complete_fallback_url (str, optional): A fallback url which, if provided, will be used to retry the Bridge Target Complete webhook delivery in case bridgeTargetCompleteUrl fails to respond. Defaults to None.
bridge_target_complete_fallback_method (str, optional): The HTTP method to use to deliver the Bridge Target Complete webhook to bridgeTargetCompleteFallbackUrl. GET or POST. Default value is POST.
username (str, optional): The username to send in the HTTP request to bridgeCompleteUrl and to bridgeTargetCompleteUrl. Defaults to None.
password (str, optional): The password to send in the HTTP request to bridgeCompleteUrl and to bridgeTargetCompleteUrl. Defaults to None.
fallback_username (str, optional): The username to send in the HTTP request to bridgeCompleteFallbackUrl and to bridgeTargetCompleteFallbackUrl. Defaults to None.
fallback_password (str, optional): The password to send in the HTTP request to bridgeCompleteFallbackUrl and to bridgeTargetCompleteFallbackUrl. Defaults to None.
tag (str, optional): A custom string that will be sent with the bridgeComplete webhook and all future webhooks of the call 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.
"""
self.target_call = target_call
self.bridge_complete_url = bridge_complete_url
Expand Down
56 changes: 56 additions & 0 deletions bandwidth/model/bxml/verbs/redirect.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
"""
redirect.py

Bandwidth's Redirect BXML verb

@copyright Bandwidth INC
"""
from ..terminal_verb import TerminalVerb


class Redirect(TerminalVerb):

def __init__(
self, redirect_url: str, redirect_method: str = None,
redirect_fallback_url: str = None,
redirect_fallback_method: str = None, username: str = None,
password: str = None, fallback_username: str = None,
fallback_password: str = None, tag: str = None
):
"""Initialize a <Redirect> verb

Args:
redirect_url (str): URL to request new BXML from. A Redirect event will be sent to this endpoint. May be a relative URL. Defaults to None.
redirect_method (str, optional): The HTTP method to use for the request to redirectUrl. GET or POST. Defaults to None.
redirect_fallback_url (str, optional): A fallback url which, if provided, will be used to retry the Redirect callback delivery in case redirectUrl fails to respond. Defaults to None.
redirect_fallback_method (str, optional): The HTTP method to use to deliver the Redirect callback to redirectFallbackUrl. GET or POST. Default value is POST. Defaults to None.
username (str, optional): The username to send in the HTTP request to redirectUrl. Defaults to None.
password (str, optional): The password to send in the HTTP request to redirectUrl. Defaults to None.
fallback_username (str, optional): The username to send in the HTTP request to redirectFallbackUrl. Defaults to None.
fallback_password (str, optional): The password to send in the HTTP request to redirectFallbackUrl. 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.
"""
self.redirect_url = redirect_url
self.redirect_method = redirect_method
self.redirect_fallback_url = redirect_fallback_url
self.redirect_fallback_method = redirect_fallback_method
self.username = username
self.password = password
self.fallback_username = fallback_username
self.fallback_password = fallback_password
self.tag = tag
super().__init__(tag="Redirect")

@property
def _attributes(self):
return {
"redirectUrl": self.redirect_url,
"redirectMethod": self.redirect_method,
"redirectFallbackUrl": self.redirect_fallback_url,
"redirectFallbackMethod": self.redirect_fallback_method,
"username": self.username,
"password": self.password,
"fallbackUsername": self.fallback_username,
"fallbackPassword": self.fallback_password,
"tag": self.tag,
}
30 changes: 30 additions & 0 deletions test/unit/bxml/test_redirect.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""
test_redirect.py

Unit tests for the <Record> BXML verb

@copyright Bandwidth Inc.
"""
import pytest
import unittest

from bandwidth.model.bxml.verb import Verb
from bandwidth.model.bxml.verbs.redirect import Redirect


class TestRecord(unittest.TestCase):

def setUp(self):
self.redirect = Redirect("https://example.com/redirect")
# self.redirect.redirect_url = "https://example.com/redirect"
self.test_verb = Verb(tag="test")

def test_to_bxml(self):
expected = '<Redirect redirectUrl="https://example.com/redirect" />'
assert(expected == self.redirect.to_bxml())


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