Skip to content

Commit

Permalink
DX-2284 Updated Ring Verb (#41)
Browse files Browse the repository at this point in the history
* DX-2284 Updated Ring Verb

* changed answerCall to string

* updated ring answerCall to accept boolean
  • Loading branch information
ckoegel authored Oct 28, 2021
1 parent 8e3c680 commit ebaa322
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
19 changes: 18 additions & 1 deletion src/Voice/Bxml/Ring.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,36 @@ class Ring extends Verb {
/**
* Sets the duration attribute for Ring
*
* @param float $duration The duration in seconds for the ring
* @param float $duration The duration in seconds for the ring
*/
public function duration($duration) {
$this->duration = $duration;
}

/**
* Sets the answerCall attribute for Ring
*
* @param boolean $answerCall Determines whether or not to answer the call when Ring is executed on an unanswered incoming call
*/
public function answerCall($answerCall) {
$this->answerCall = $answerCall;
}

public function toBxml($doc) {
$element = $doc->createElement("Ring");

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

if(isset($this->answerCall)) {
if ($this->answerCall) {
$element->setattribute("answerCall", "true");
} else {
$element->setattribute("answerCall", "false");
}
}

return $element;
}
}
3 changes: 2 additions & 1 deletion tests/BxmlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -370,11 +370,12 @@ public function testBridge() {
public function testRing() {
$ring = new BandwidthLib\Voice\Bxml\Ring();
$ring->duration(5);
$ring->answerCall(false);

$response = new BandwidthLib\Voice\Bxml\Response();
$response->addVerb($ring);

$expectedXml = '<?xml version="1.0" encoding="UTF-8"?><Response><Ring duration="5"/></Response>';
$expectedXml = '<?xml version="1.0" encoding="UTF-8"?><Response><Ring duration="5" answerCall="false"/></Response>';
$responseXml = $response->toBxml();
$this->assertEquals($expectedXml, $responseXml);
}
Expand Down

0 comments on commit ebaa322

Please sign in to comment.