|
| 1 | +""" |
| 2 | +bridge.py |
| 3 | +
|
| 4 | +Representation of Bandwidth's speak sentence BXML verb |
| 5 | +
|
| 6 | +@copyright Bandwidth INC |
| 7 | +""" |
| 8 | + |
| 9 | +from lxml import etree |
| 10 | + |
| 11 | +from .base_verb import AbstractBxmlVerb |
| 12 | + |
| 13 | +import re |
| 14 | + |
| 15 | +BRIDGE_TAG = "Bridge" |
| 16 | + |
| 17 | +class Bridge(AbstractBxmlVerb): |
| 18 | + |
| 19 | + def __init__(self, call_id, bridge_complete_url=None, bridge_complete_method=None, |
| 20 | + bridge_target_complete_url=None, bridge_target_complete_method=None, |
| 21 | + username=None, password=None, tag=None): |
| 22 | + """ |
| 23 | + Initializes the Bridge class with the following parameters |
| 24 | +
|
| 25 | + :param str call_id: The call to bridge |
| 26 | + :param str bridge_complete_url: URL to send the bridge complete event to |
| 27 | + :param str bridge_complete_method: HTTP method to send the bridge complete event |
| 28 | + :param str bridge_target_complete_url: URL to send the bridge target complete event to |
| 29 | + :param str bridge_target_complete_method: HTTP method to send the bridge target complete event |
| 30 | + :param str username: HTTP basic auth username for events |
| 31 | + :param str password: HTTP basic auth password for events |
| 32 | + :param str tag: Custom tag to include in callbacks |
| 33 | + """ |
| 34 | + self.call_id = call_id |
| 35 | + self.bridge_complete_url = bridge_complete_url |
| 36 | + self.bridge_complete_method = bridge_complete_method |
| 37 | + self.bridge_target_complete_url = bridge_target_complete_url |
| 38 | + self.bridge_target_complete_method = bridge_target_complete_method |
| 39 | + self.username = username |
| 40 | + self.password = password |
| 41 | + self.tag = tag |
| 42 | + |
| 43 | + def to_bxml(self): |
| 44 | + root = etree.Element(BRIDGE_TAG) |
| 45 | + root.text = self.call_id |
| 46 | + if self.bridge_complete_url is not None: |
| 47 | + root.set("bridgeCompleteUrl", self.bridge_complete_url) |
| 48 | + if self.bridge_complete_method is not None: |
| 49 | + root.set("bridgeCompleteMethod", self.bridge_complete_method) |
| 50 | + if self.bridge_target_complete_url is not None: |
| 51 | + root.set("bridgeTargetCompleteUrl", self.bridge_target_complete_url) |
| 52 | + if self.bridge_target_complete_method is not None: |
| 53 | + root.set("bridgeTargetCompleteMethod", self.bridge_target_complete_method) |
| 54 | + if self.username is not None: |
| 55 | + root.set("username", self.username) |
| 56 | + if self.password is not None: |
| 57 | + root.set("password", self.password) |
| 58 | + if self.tag is not None: |
| 59 | + root.set("tag", self.tag) |
| 60 | + return etree.tostring(root).decode() |
0 commit comments