Skip to content

Commit

Permalink
Merge pull request #32 from Bandwidth/EDGE-630
Browse files Browse the repository at this point in the history
EDGE-630 Add voiceCallId to generateTransferBxmlVerb for debugging
  • Loading branch information
acopeland-bw authored Jul 26, 2021
2 parents 6f3d5df + ae5cd75 commit 2cb201f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
21 changes: 17 additions & 4 deletions src/WebRtc/Utils/WebRtcTransfer.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,24 @@
namespace BandwidthLib\WebRtc\Utils;

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

public static function generateTransferBxmlVerb($deviceToken, $sipUri = "sip:sipx.webrtc.bandwidth.com:5060") {
return '<Transfer><SipUri uui="' . $deviceToken . ';encoding=jwt">' . $sipUri . '</SipUri></Transfer>';
public static function generateTransferBxmlVerb($deviceToken, $voiceCallId, $sipUri = "sip:sipx.webrtc.bandwidth.com:5060") {
/**
* Returns the Transfer verb to perform the SIP transfer
* @param string $deviceToken The device token
* @param array $voiceCallId The Bandwidth Voice Call Id
* @return string $sipUri The SIP URI to transfer the call to
*/
$formattedCallId = substr(str_replace("-", "", $voiceCallId), 1);
return '<Transfer><SipUri uui="' . $formattedCallId . ';encoding=base64,' . $deviceToken . ';encoding=jwt">' . $sipUri . '</SipUri></Transfer>';
}
}
8 changes: 4 additions & 4 deletions tests/WebRtcBxmlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
final class WebRtcBxmlTest extends TestCase
{
public function testGenerateBxml() {
$expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Transfer><SipUri uui="asdf;encoding=jwt">sip:sipx.webrtc.bandwidth.com:5060</SipUri></Transfer></Response>';
$actual = BandwidthLib\WebRtc\Utils\WebRtcTransfer::generateBxml('asdf');
$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>';
$actual = BandwidthLib\WebRtc\Utils\WebRtcTransfer::generateBxml('asdf', 'c-93d6f3c0-be584596-0b74-4fa2-8015-d8ede84bd1a4');
$this->assertEquals($expected, $actual);
}

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

0 comments on commit 2cb201f

Please sign in to comment.