Skip to content

Commit 1f88cd2

Browse files
authored
Dx 1669 1674 sip uri and tag bxml (#15)
* DX-1674 sip uri * DX-1669 tag * Changed variable name to sip
1 parent c8e1044 commit 1f88cd2

File tree

3 files changed

+231
-0
lines changed

3 files changed

+231
-0
lines changed

src/Voice/Bxml/SipUri.php

Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
<?php
2+
/**
3+
* SipUri.php
4+
*
5+
* Implementation of the BXML SipUri tag
6+
*
7+
* * @copyright Bandwidth INC
8+
*/
9+
10+
namespace BandwidthLib\Voice\Bxml;
11+
12+
require_once "Verb.php";
13+
14+
class SipUri extends Verb {
15+
16+
/**
17+
* Constructor for SipUri
18+
*
19+
* @param string $sip The sip uri destination
20+
*/
21+
public function __construct($sip) {
22+
$this->sip = $sip;
23+
}
24+
25+
/**
26+
* Sets the username attribute for SipUri
27+
*
28+
* @param string $username The username for http authentication on the audio url
29+
*/
30+
public function username($username) {
31+
$this->username = $username;
32+
}
33+
34+
/**
35+
* Sets the password attribute for SipUri
36+
*
37+
* @param string $password The password for http authentication on the audio url
38+
*/
39+
public function password($password) {
40+
$this->password = $password;
41+
}
42+
43+
/**
44+
* Sets the transferAnswerUrl attribute for SipUri
45+
*
46+
* @param string $transferAnswerUrl The url to receive the transfer answered callback
47+
*/
48+
public function transferAnswerUrl($transferAnswerUrl) {
49+
$this->transferAnswerUrl = $transferAnswerUrl;
50+
}
51+
52+
/**
53+
* Sets the transferAnswerMethod attribute for SipUri
54+
*
55+
* @param string $transferAnswerMethod The http method to send the transfer answered callback
56+
*/
57+
public function transferAnswerMethod($transferAnswerMethod) {
58+
$this->transferAnswerMethod = $transferAnswerMethod;
59+
}
60+
61+
/**
62+
* Sets the transferDisconnectUrl attribute for SipUri
63+
*
64+
* @param string $transferDisconnectUrl The url to receive the transfer disconnect callback
65+
*/
66+
public function transferDisconnectUrl($transferDisconnectUrl) {
67+
$this->transferDisconnectUrl = $transferDisconnectUrl;
68+
}
69+
70+
/**
71+
* Sets the transferDisconnectMethod attribute for SipUri
72+
*
73+
* @param string $transferDisconnectMethod The http method to send the transfer disconnect callback
74+
*/
75+
public function transferDisconnectMethod($transferDisconnectMethod) {
76+
$this->transferDisconnectMethod = $transferDisconnectMethod;
77+
}
78+
79+
/**
80+
* Sets the tag attribute for SipUri
81+
*
82+
* @param string $tag A custom string to be included in callbacks
83+
*/
84+
public function tag($tag) {
85+
$this->tag = $tag;
86+
}
87+
88+
/**
89+
* Sets the uui attribute for SipUri
90+
*
91+
* @param string $uui The value of the `User-To-User` header to send within the initial `INVITE`
92+
*/
93+
public function uui($uui) {
94+
$this->uui = $uui;
95+
}
96+
97+
/**
98+
* Sets the transferAnswerFallbackUrl attribute for SipUri
99+
*
100+
* @param string $transferAnswerFallbackUrl Fallback URL for transfer answer events
101+
*/
102+
public function transferAnswerFallbackUrl($transferAnswerFallbackUrl) {
103+
$this->transferAnswerFallbackUrl = $transferAnswerFallbackUrl;
104+
}
105+
106+
/**
107+
* Sets the transferAnswerFallbackMethod attribute for SipUri
108+
*
109+
* @param string $transferAnswerFallbackMethod HTTP method for fallback events
110+
*/
111+
public function transferAnswerFallbackMethod($transferAnswerFallbackMethod) {
112+
$this->transferAnswerFallbackMethod = $transferAnswerFallbackMethod;
113+
}
114+
115+
/**
116+
* Sets the fallbackUsername attribute for SipUri
117+
*
118+
* @param string $fallbackUsername HTTP basic auth username for fallback events
119+
*/
120+
public function fallbackUsername($fallbackUsername) {
121+
$this->fallbackUsername = $fallbackUsername;
122+
}
123+
124+
/**
125+
* Sets the fallbackPassword attribute for SipUri
126+
*
127+
* @param string $fallbackPassword HTTP basic auth password for fallback events
128+
*/
129+
public function fallbackPassword($fallbackPassword) {
130+
$this->fallbackPassword = $fallbackPassword;
131+
}
132+
133+
public function toBxml($doc) {
134+
$element = $doc->createElement("SipUri", $this->sip);
135+
136+
if(isset($this->username)) {
137+
$element->setAttribute("username", $this->username);
138+
}
139+
140+
if(isset($this->password)) {
141+
$element->setAttribute("password", $this->password);
142+
}
143+
144+
if(isset($this->tag)) {
145+
$element->setAttribute("tag", $this->tag);
146+
}
147+
148+
if(isset($this->uui)) {
149+
$element->setAttribute("uui", $this->uui);
150+
}
151+
152+
if(isset($this->transferAnswerUrl)) {
153+
$element->setAttribute("transferAnswerUrl", $this->transferAnswerUrl);
154+
}
155+
156+
if(isset($this->transferAnswerMethod)) {
157+
$element->setAttribute("transferAnswerMethod", $this->transferAnswerMethod);
158+
}
159+
160+
if(isset($this->transferDisconnectUrl)) {
161+
$element->setAttribute("transferDisconnectUrl", $this->transferDisconnectUrl);
162+
}
163+
164+
if(isset($this->transferDisconnectMethod)) {
165+
$element->setAttribute("transferDisconnectMethod", $this->transferDisconnectMethod);
166+
}
167+
168+
if(isset($this->transferAnswerFallbackUrl)) {
169+
$element->setAttribute("transferAnswerFallbackUrl", $this->transferAnswerFallbackUrl);
170+
}
171+
172+
if(isset($this->transferAnswerFallbackMethod)) {
173+
$element->setAttribute("transferAnswerFallbackMethod", $this->transferAnswerFallbackMethod);
174+
}
175+
176+
if(isset($this->fallbackUsername)) {
177+
$element->setAttribute("fallbackUsername", $this->fallbackUsername);
178+
}
179+
180+
if(isset($this->fallbackPassword)) {
181+
$element->setAttribute("fallbackPassword", $this->fallbackPassword);
182+
}
183+
184+
return $element;
185+
}
186+
}

src/Voice/Bxml/Tag.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
/**
3+
* Tag.php
4+
*
5+
* Implementation of the BXML Tag verb
6+
*
7+
* * @copyright Bandwidth INC
8+
*/
9+
10+
namespace BandwidthLib\Voice\Bxml;
11+
12+
require_once "Verb.php";
13+
14+
class Tag extends Verb {
15+
16+
/**
17+
* Constructor for Tag
18+
*
19+
* @param string $tag The value to set the call tag to
20+
*/
21+
public function __construct($tag) {
22+
$this->tag = $tag;
23+
}
24+
25+
public function toBxml($doc) {
26+
$element = $doc->createElement("Tag", $this->tag);
27+
28+
return $element;
29+
}
30+
}

src/Voice/Bxml/Transfer.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,15 @@ public function phoneNumbers($phoneNumbers) {
103103
$this->phoneNumbers = $phoneNumbers;
104104
}
105105

106+
/**
107+
* Sets the SipUri tags to be included in the Transfer
108+
*
109+
* @param list<SipUri> $sipUris The list of SipUri tags
110+
*/
111+
public function sipUris($sipUris) {
112+
$this->sipUris = $sipUris;
113+
}
114+
106115
/**
107116
* Sets the transferCompleteFallbackUrl attribute for Transfer
108117
*
@@ -200,6 +209,12 @@ public function toBxml($doc) {
200209
}
201210
}
202211

212+
if(isset($this->sipUris)) {
213+
foreach ($this->sipUris as $sipUri) {
214+
$element->appendChild($sipUri->toBxml($doc));
215+
}
216+
}
217+
203218
return $element;
204219
}
205220
}

0 commit comments

Comments
 (0)