|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * SipUri.php |
| 4 | + * |
| 5 | + * Implementation of the BXML SipUri tag |
| 6 | + * |
| 7 | + * * @copyright Bandwidth INC |
| 8 | + */ |
| 9 | + |
| 10 | +namespace BandwidthLib\Voice\Bxml; |
| 11 | + |
| 12 | +require_once "Verb.php"; |
| 13 | + |
| 14 | +class SipUri extends Verb { |
| 15 | + |
| 16 | + /** |
| 17 | + * Constructor for SipUri |
| 18 | + * |
| 19 | + * @param string $sip The sip uri destination |
| 20 | + */ |
| 21 | + public function __construct($sip) { |
| 22 | + $this->sip = $sip; |
| 23 | + } |
| 24 | + |
| 25 | + /** |
| 26 | + * Sets the username attribute for SipUri |
| 27 | + * |
| 28 | + * @param string $username The username for http authentication on the audio url |
| 29 | + */ |
| 30 | + public function username($username) { |
| 31 | + $this->username = $username; |
| 32 | + } |
| 33 | + |
| 34 | + /** |
| 35 | + * Sets the password attribute for SipUri |
| 36 | + * |
| 37 | + * @param string $password The password for http authentication on the audio url |
| 38 | + */ |
| 39 | + public function password($password) { |
| 40 | + $this->password = $password; |
| 41 | + } |
| 42 | + |
| 43 | + /** |
| 44 | + * Sets the transferAnswerUrl attribute for SipUri |
| 45 | + * |
| 46 | + * @param string $transferAnswerUrl The url to receive the transfer answered callback |
| 47 | + */ |
| 48 | + public function transferAnswerUrl($transferAnswerUrl) { |
| 49 | + $this->transferAnswerUrl = $transferAnswerUrl; |
| 50 | + } |
| 51 | + |
| 52 | + /** |
| 53 | + * Sets the transferAnswerMethod attribute for SipUri |
| 54 | + * |
| 55 | + * @param string $transferAnswerMethod The http method to send the transfer answered callback |
| 56 | + */ |
| 57 | + public function transferAnswerMethod($transferAnswerMethod) { |
| 58 | + $this->transferAnswerMethod = $transferAnswerMethod; |
| 59 | + } |
| 60 | + |
| 61 | + /** |
| 62 | + * Sets the transferDisconnectUrl attribute for SipUri |
| 63 | + * |
| 64 | + * @param string $transferDisconnectUrl The url to receive the transfer disconnect callback |
| 65 | + */ |
| 66 | + public function transferDisconnectUrl($transferDisconnectUrl) { |
| 67 | + $this->transferDisconnectUrl = $transferDisconnectUrl; |
| 68 | + } |
| 69 | + |
| 70 | + /** |
| 71 | + * Sets the transferDisconnectMethod attribute for SipUri |
| 72 | + * |
| 73 | + * @param string $transferDisconnectMethod The http method to send the transfer disconnect callback |
| 74 | + */ |
| 75 | + public function transferDisconnectMethod($transferDisconnectMethod) { |
| 76 | + $this->transferDisconnectMethod = $transferDisconnectMethod; |
| 77 | + } |
| 78 | + |
| 79 | + /** |
| 80 | + * Sets the tag attribute for SipUri |
| 81 | + * |
| 82 | + * @param string $tag A custom string to be included in callbacks |
| 83 | + */ |
| 84 | + public function tag($tag) { |
| 85 | + $this->tag = $tag; |
| 86 | + } |
| 87 | + |
| 88 | + /** |
| 89 | + * Sets the uui attribute for SipUri |
| 90 | + * |
| 91 | + * @param string $uui The value of the `User-To-User` header to send within the initial `INVITE` |
| 92 | + */ |
| 93 | + public function uui($uui) { |
| 94 | + $this->uui = $uui; |
| 95 | + } |
| 96 | + |
| 97 | + /** |
| 98 | + * Sets the transferAnswerFallbackUrl attribute for SipUri |
| 99 | + * |
| 100 | + * @param string $transferAnswerFallbackUrl Fallback URL for transfer answer events |
| 101 | + */ |
| 102 | + public function transferAnswerFallbackUrl($transferAnswerFallbackUrl) { |
| 103 | + $this->transferAnswerFallbackUrl = $transferAnswerFallbackUrl; |
| 104 | + } |
| 105 | + |
| 106 | + /** |
| 107 | + * Sets the transferAnswerFallbackMethod attribute for SipUri |
| 108 | + * |
| 109 | + * @param string $transferAnswerFallbackMethod HTTP method for fallback events |
| 110 | + */ |
| 111 | + public function transferAnswerFallbackMethod($transferAnswerFallbackMethod) { |
| 112 | + $this->transferAnswerFallbackMethod = $transferAnswerFallbackMethod; |
| 113 | + } |
| 114 | + |
| 115 | + /** |
| 116 | + * Sets the fallbackUsername attribute for SipUri |
| 117 | + * |
| 118 | + * @param string $fallbackUsername HTTP basic auth username for fallback events |
| 119 | + */ |
| 120 | + public function fallbackUsername($fallbackUsername) { |
| 121 | + $this->fallbackUsername = $fallbackUsername; |
| 122 | + } |
| 123 | + |
| 124 | + /** |
| 125 | + * Sets the fallbackPassword attribute for SipUri |
| 126 | + * |
| 127 | + * @param string $fallbackPassword HTTP basic auth password for fallback events |
| 128 | + */ |
| 129 | + public function fallbackPassword($fallbackPassword) { |
| 130 | + $this->fallbackPassword = $fallbackPassword; |
| 131 | + } |
| 132 | + |
| 133 | + public function toBxml($doc) { |
| 134 | + $element = $doc->createElement("SipUri", $this->sip); |
| 135 | + |
| 136 | + if(isset($this->username)) { |
| 137 | + $element->setAttribute("username", $this->username); |
| 138 | + } |
| 139 | + |
| 140 | + if(isset($this->password)) { |
| 141 | + $element->setAttribute("password", $this->password); |
| 142 | + } |
| 143 | + |
| 144 | + if(isset($this->tag)) { |
| 145 | + $element->setAttribute("tag", $this->tag); |
| 146 | + } |
| 147 | + |
| 148 | + if(isset($this->uui)) { |
| 149 | + $element->setAttribute("uui", $this->uui); |
| 150 | + } |
| 151 | + |
| 152 | + if(isset($this->transferAnswerUrl)) { |
| 153 | + $element->setAttribute("transferAnswerUrl", $this->transferAnswerUrl); |
| 154 | + } |
| 155 | + |
| 156 | + if(isset($this->transferAnswerMethod)) { |
| 157 | + $element->setAttribute("transferAnswerMethod", $this->transferAnswerMethod); |
| 158 | + } |
| 159 | + |
| 160 | + if(isset($this->transferDisconnectUrl)) { |
| 161 | + $element->setAttribute("transferDisconnectUrl", $this->transferDisconnectUrl); |
| 162 | + } |
| 163 | + |
| 164 | + if(isset($this->transferDisconnectMethod)) { |
| 165 | + $element->setAttribute("transferDisconnectMethod", $this->transferDisconnectMethod); |
| 166 | + } |
| 167 | + |
| 168 | + if(isset($this->transferAnswerFallbackUrl)) { |
| 169 | + $element->setAttribute("transferAnswerFallbackUrl", $this->transferAnswerFallbackUrl); |
| 170 | + } |
| 171 | + |
| 172 | + if(isset($this->transferAnswerFallbackMethod)) { |
| 173 | + $element->setAttribute("transferAnswerFallbackMethod", $this->transferAnswerFallbackMethod); |
| 174 | + } |
| 175 | + |
| 176 | + if(isset($this->fallbackUsername)) { |
| 177 | + $element->setAttribute("fallbackUsername", $this->fallbackUsername); |
| 178 | + } |
| 179 | + |
| 180 | + if(isset($this->fallbackPassword)) { |
| 181 | + $element->setAttribute("fallbackPassword", $this->fallbackPassword); |
| 182 | + } |
| 183 | + |
| 184 | + return $element; |
| 185 | + } |
| 186 | +} |
0 commit comments