diff --git a/src/Voice/Bxml/StartStream.php b/src/Voice/Bxml/StartStream.php index 029cb1d..d7e1ef4 100644 --- a/src/Voice/Bxml/StartStream.php +++ b/src/Voice/Bxml/StartStream.php @@ -77,6 +77,15 @@ public function streamEventMethod($streamEventMethod) { $this->streamEventMethod = $streamEventMethod; } + /** + * Sets the tag. You may specify up to 12 elements nested within a tag. These elements define optional user specified parameters that will be sent to the destination URL when the stream is first started. + * + * @param list $streamParams The list of StreamParam tags + */ + public function streamParams($streamParams) { + $this->streamParams = $streamParams; + } + public function toBxml($doc) { $element = $doc->createElement("StartStream"); @@ -108,6 +117,12 @@ public function toBxml($doc) { $element->setattribute("streamEventMethod", $this->streamEventMethod); } + if(isset($this->streamParams)) { + foreach ($this->streamParams as $streamParam) { + $element->appendChild($streamParam->toBxml($doc)); + } + } + return $element; } } diff --git a/src/Voice/Bxml/StreamParam.php b/src/Voice/Bxml/StreamParam.php new file mode 100644 index 0000000..cafff17 --- /dev/null +++ b/src/Voice/Bxml/StreamParam.php @@ -0,0 +1,47 @@ + elements nested within a tag. These elements define optional user specified parameters that will be sent to the destination URL when the stream is first started. + * + * * @copyright Bandwidth INC + */ + +namespace BandwidthLib\Voice\Bxml; + +require_once "Verb.php"; + +class StreamParam extends Verb { + + /** + * Sets the name attribute for StreamParam + * + * @param string $name (required) The name of this parameter, up to 256 characters. + */ + public function name($name) { + $this->name = $name; + } + + /** + * Sets the value attribute for StreamParam + * + * @param string $value (required) The value of this parameter, up to 2048 characters. + */ + public function value($value) { + $this->value = $value; + } + + public function toBxml($doc) { + $element = $doc->createElement("StreamParam"); + + if(isset($this->name)) { + $element->setAttribute("name", $this->name); + } + + if(isset($this->value)) { + $element->setAttribute("value", $this->value); + } + + return $element; + } +} diff --git a/tests/BxmlTest.php b/tests/BxmlTest.php index a81417e..d7d15f1 100644 --- a/tests/BxmlTest.php +++ b/tests/BxmlTest.php @@ -352,6 +352,12 @@ public function testStopRecording() { $this->assertEquals($expectedXml, $responseXml); } public function testStartStream() { + $streamParam1 = new BandwidthLib\Voice\Bxml\StreamParam(); + $streamParam1->name("name1"); + $streamParam1->value("value1"); + $streamParam2 = new BandwidthLib\Voice\Bxml\StreamParam(); + $streamParam2->name("name2"); + $streamParam2->value("value2"); $startStream = new BandwidthLib\Voice\Bxml\StartStream(); $startStream->name("test"); $startStream->tracks("inbound"); @@ -360,11 +366,13 @@ public function testStartStream() { $startStream->username("user"); $startStream->password("pass"); $startStream->streamEventUrl("https://url.com"); + $startStream->streamParams(array($streamParam1, $streamParam2)); + $response = new BandwidthLib\Voice\Bxml\Response(); $response->addVerb($startStream); - $expectedXml = ''; + $expectedXml = ''; $responseXml = $response->toBxml(); $this->assertEquals($expectedXml, $responseXml); }