Skip to content

Commit 62f13c3

Browse files
committed
Add documentation and fix tests
1 parent 684ebe0 commit 62f13c3

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/WebRtc/Utils/WebRtcTransfer.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,22 @@
1111

1212
class WebRtcTransfer {
1313
public static function generateBxml($deviceToken, $voiceCallId, $sipUri = "sip:sipx.webrtc.bandwidth.com:5060") {
14+
/**
15+
* Returns BXML string with WebRTC a device token to perform a SIP transfer
16+
* @param string $deviceToken The device token
17+
* @param array $voiceCallId The Bandwidth Voice Call Id
18+
* @return string $sipUri The SIP URI to transfer the call to
19+
*/
1420
return '<?xml version="1.0" encoding="UTF-8"?><Response>' . WebRtcTransfer::generateTransferBxmlVerb($deviceToken, $voiceCallId, $sipUri) . '</Response>';
1521
}
1622

1723
public static function generateTransferBxmlVerb($deviceToken, $voiceCallId, $sipUri = "sip:sipx.webrtc.bandwidth.com:5060") {
24+
/**
25+
* Returns the Transfer verb to perform the SIP transfer
26+
* @param string $deviceToken The device token
27+
* @param array $voiceCallId The Bandwidth Voice Call Id
28+
* @return string $sipUri The SIP URI to transfer the call to
29+
*/
1830
$formattedCallId = substr(str_replace("-", "", $voiceCallId), 1);
1931
return '<Transfer><SipUri uui="' . $formattedCallId . ';encoding=base64' . $deviceToken . ';encoding=jwt">' . $sipUri . '</SipUri></Transfer>';
2032
}

tests/WebRtcBxmlTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
final class WebRtcBxmlTest extends TestCase
1414
{
1515
public function testGenerateBxml() {
16-
$expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Transfer><SipUri uui="asdf;encoding=jwt">sip:sipx.webrtc.bandwidth.com:5060</SipUri></Transfer></Response>';
17-
$actual = BandwidthLib\WebRtc\Utils\WebRtcTransfer::generateBxml('asdf');
16+
$expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Transfer><SipUri uui="93d6f3c0be5845960b744fa28015d8ede84bd1a4;encoding=base64,asdf;encoding=jwt">sip:sipx.webrtc.bandwidth.com:5060</SipUri></Transfer></Response>';
17+
$actual = BandwidthLib\WebRtc\Utils\WebRtcTransfer::generateBxml('asdf', 'c-93d6f3c0-be584596-0b74-4fa2-8015-d8ede84bd1a4');
1818
$this->assertEquals($expected, $actual);
1919
}
2020

2121
public function testGenerateTransferBxmlVerb() {
22-
$expected = '<Transfer><SipUri uui="asdf;encoding=jwt">sip:sipx.webrtc.bandwidth.com:5060</SipUri></Transfer>';
23-
$actual = BandwidthLib\WebRtc\Utils\WebRtcTransfer::generateTransferBxmlVerb('asdf');
22+
$expected = '<Transfer><SipUri uui="93d6f3c0be5845960b744fa28015d8ede84bd1a4;encoding=base64,asdf;encoding=jwt">sip:sipx.webrtc.bandwidth.com:5060</SipUri></Transfer>';
23+
$actual = BandwidthLib\WebRtc\Utils\WebRtcTransfer::generateTransferBxmlVerb('asdf', 'c-93d6f3c0-be584596-0b74-4fa2-8015-d8ede84bd1a4');
2424
$this->assertEquals($expected, $actual);
2525
}
2626
}

0 commit comments

Comments
 (0)