Skip to content

Commit

Permalink
Dx 1669 1674 sip uri and tag bxml (#15)
Browse files Browse the repository at this point in the history
* DX-1674 sip uri

* DX-1669 tag

* Changed variable name to sip
  • Loading branch information
jmulford-bw authored Dec 9, 2020
1 parent c8e1044 commit 1f88cd2
Show file tree
Hide file tree
Showing 3 changed files with 231 additions and 0 deletions.
186 changes: 186 additions & 0 deletions src/Voice/Bxml/SipUri.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
<?php
/**
* SipUri.php
*
* Implementation of the BXML SipUri tag
*
* * @copyright Bandwidth INC
*/

namespace BandwidthLib\Voice\Bxml;

require_once "Verb.php";

class SipUri extends Verb {

/**
* Constructor for SipUri
*
* @param string $sip The sip uri destination
*/
public function __construct($sip) {
$this->sip = $sip;
}

/**
* Sets the username attribute for SipUri
*
* @param string $username The username for http authentication on the audio url
*/
public function username($username) {
$this->username = $username;
}

/**
* Sets the password attribute for SipUri
*
* @param string $password The password for http authentication on the audio url
*/
public function password($password) {
$this->password = $password;
}

/**
* Sets the transferAnswerUrl attribute for SipUri
*
* @param string $transferAnswerUrl The url to receive the transfer answered callback
*/
public function transferAnswerUrl($transferAnswerUrl) {
$this->transferAnswerUrl = $transferAnswerUrl;
}

/**
* Sets the transferAnswerMethod attribute for SipUri
*
* @param string $transferAnswerMethod The http method to send the transfer answered callback
*/
public function transferAnswerMethod($transferAnswerMethod) {
$this->transferAnswerMethod = $transferAnswerMethod;
}

/**
* Sets the transferDisconnectUrl attribute for SipUri
*
* @param string $transferDisconnectUrl The url to receive the transfer disconnect callback
*/
public function transferDisconnectUrl($transferDisconnectUrl) {
$this->transferDisconnectUrl = $transferDisconnectUrl;
}

/**
* Sets the transferDisconnectMethod attribute for SipUri
*
* @param string $transferDisconnectMethod The http method to send the transfer disconnect callback
*/
public function transferDisconnectMethod($transferDisconnectMethod) {
$this->transferDisconnectMethod = $transferDisconnectMethod;
}

/**
* Sets the tag attribute for SipUri
*
* @param string $tag A custom string to be included in callbacks
*/
public function tag($tag) {
$this->tag = $tag;
}

/**
* Sets the uui attribute for SipUri
*
* @param string $uui The value of the `User-To-User` header to send within the initial `INVITE`
*/
public function uui($uui) {
$this->uui = $uui;
}

/**
* Sets the transferAnswerFallbackUrl attribute for SipUri
*
* @param string $transferAnswerFallbackUrl Fallback URL for transfer answer events
*/
public function transferAnswerFallbackUrl($transferAnswerFallbackUrl) {
$this->transferAnswerFallbackUrl = $transferAnswerFallbackUrl;
}

/**
* Sets the transferAnswerFallbackMethod attribute for SipUri
*
* @param string $transferAnswerFallbackMethod HTTP method for fallback events
*/
public function transferAnswerFallbackMethod($transferAnswerFallbackMethod) {
$this->transferAnswerFallbackMethod = $transferAnswerFallbackMethod;
}

/**
* Sets the fallbackUsername attribute for SipUri
*
* @param string $fallbackUsername HTTP basic auth username for fallback events
*/
public function fallbackUsername($fallbackUsername) {
$this->fallbackUsername = $fallbackUsername;
}

/**
* Sets the fallbackPassword attribute for SipUri
*
* @param string $fallbackPassword HTTP basic auth password for fallback events
*/
public function fallbackPassword($fallbackPassword) {
$this->fallbackPassword = $fallbackPassword;
}

public function toBxml($doc) {
$element = $doc->createElement("SipUri", $this->sip);

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

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

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

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

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

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

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

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

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

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

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

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

return $element;
}
}
30 changes: 30 additions & 0 deletions src/Voice/Bxml/Tag.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/**
* Tag.php
*
* Implementation of the BXML Tag verb
*
* * @copyright Bandwidth INC
*/

namespace BandwidthLib\Voice\Bxml;

require_once "Verb.php";

class Tag extends Verb {

/**
* Constructor for Tag
*
* @param string $tag The value to set the call tag to
*/
public function __construct($tag) {
$this->tag = $tag;
}

public function toBxml($doc) {
$element = $doc->createElement("Tag", $this->tag);

return $element;
}
}
15 changes: 15 additions & 0 deletions src/Voice/Bxml/Transfer.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,15 @@ public function phoneNumbers($phoneNumbers) {
$this->phoneNumbers = $phoneNumbers;
}

/**
* Sets the SipUri tags to be included in the Transfer
*
* @param list<SipUri> $sipUris The list of SipUri tags
*/
public function sipUris($sipUris) {
$this->sipUris = $sipUris;
}

/**
* Sets the transferCompleteFallbackUrl attribute for Transfer
*
Expand Down Expand Up @@ -200,6 +209,12 @@ public function toBxml($doc) {
}
}

if(isset($this->sipUris)) {
foreach ($this->sipUris as $sipUri) {
$element->appendChild($sipUri->toBxml($doc));
}
}

return $element;
}
}

0 comments on commit 1f88cd2

Please sign in to comment.