Skip to content

SWI-4587 add transferCallerDisplayName #69

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 21, 2024
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
15 changes: 15 additions & 0 deletions src/Voice/Bxml/Transfer.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ class Transfer extends Verb {
* @var string
*/
private $transferCallerId;
/**
* @var string
*/
private $transferCallerDisplayName;
/**
* @var string
*/
Expand Down Expand Up @@ -114,6 +118,13 @@ public function transferCallerId(string $transferCallerId) {
$this->transferCallerId = $transferCallerId;
}

/**
* Sets the transferCallerDisplayName attribute for Transfer
*/
public function transferCallerDisplayName(string $transferCallerDisplayName) {
$this->transferCallerDisplayName = $transferCallerDisplayName;
}

/**
* Sets the callTimeout attribute for Transfer
*
Expand Down Expand Up @@ -231,6 +242,10 @@ public function toBxml(DOMDocument $doc) {
$element->setAttribute("transferCallerId", $this->transferCallerId);
}

if(isset($this->transferCallerDisplayName)) {
$element->setAttribute("transferCallerDisplayName", $this->transferCallerDisplayName);
}

if(isset($this->callTimeout)) {
$element->setAttribute("callTimeout", $this->callTimeout);
}
Expand Down
3 changes: 2 additions & 1 deletion tests/BxmlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ public function testTransfer() {
$number2->fallbackPassword("fpass");
$transfer = new BandwidthLib\Voice\Bxml\Transfer();
$transfer->transferCallerId("+18999999999");
$transfer->transferCallerDisplayName("test");
$transfer->transferCompleteUrl("https://test.com");
$transfer->transferCompleteMethod("GET");
$transfer->username("user");
Expand All @@ -293,7 +294,7 @@ public function testTransfer() {
$transfer->fallbackPassword("fpassw");
$response = new BandwidthLib\Voice\Bxml\Response();
$response->addVerb($transfer);
$expectedXml = '<?xml version="1.0" encoding="UTF-8"?><Response><Transfer username="user" password="pass" tag="tag" transferCompleteUrl="https://test.com" transferCompleteMethod="GET" transferCallerId="+18999999999" callTimeout="3" diversionTreatment="none" diversionReason="away" transferCompleteFallbackUrl="https://test3.com" transferCompleteFallbackMethod="POST" fallbackUsername="fusern" fallbackPassword="fpassw"><PhoneNumber username="user" password="pass" tag="tag" transferAnswerUrl="https://test.com" transferAnswerMethod="GET">+17777777777</PhoneNumber><PhoneNumber username="user2" password="pass2" tag="tag2" transferAnswerUrl="https://test2.com" transferAnswerMethod="GET" transferAnswerFallbackUrl="https://test3.com" transferAnswerFallbackMethod="POST" fallbackUsername="fuser" fallbackPassword="fpass">+17777777779</PhoneNumber></Transfer></Response>';
$expectedXml = '<?xml version="1.0" encoding="UTF-8"?><Response><Transfer username="user" password="pass" tag="tag" transferCompleteUrl="https://test.com" transferCompleteMethod="GET" transferCallerId="+18999999999" transferCallerDisplayName="test" callTimeout="3" diversionTreatment="none" diversionReason="away" transferCompleteFallbackUrl="https://test3.com" transferCompleteFallbackMethod="POST" fallbackUsername="fusern" fallbackPassword="fpassw"><PhoneNumber username="user" password="pass" tag="tag" transferAnswerUrl="https://test.com" transferAnswerMethod="GET">+17777777777</PhoneNumber><PhoneNumber username="user2" password="pass2" tag="tag2" transferAnswerUrl="https://test2.com" transferAnswerMethod="GET" transferAnswerFallbackUrl="https://test3.com" transferAnswerFallbackMethod="POST" fallbackUsername="fuser" fallbackPassword="fpass">+17777777779</PhoneNumber></Transfer></Response>';
$responseXml = $response->toBxml();
$this->assertEquals($expectedXml, $responseXml);
}
Expand Down