From 7ca8f670b65c7be245b40d6d750c8bec80a77c5f Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 15 Sep 2022 00:19:18 -0400 Subject: [PATCH 1/4] Added StreamParam for StartStream --- src/Voice/Bxml/StreamParam.php | 58 ++++++++++++++++++++++++++++++++++ tests/BxmlTest.php | 10 +++++- 2 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 src/Voice/Bxml/StreamParam.php diff --git a/src/Voice/Bxml/StreamParam.php b/src/Voice/Bxml/StreamParam.php new file mode 100644 index 0000000..513f107 --- /dev/null +++ b/src/Voice/Bxml/StreamParam.php @@ -0,0 +1,58 @@ + 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. + */ + public function __construct($StreamParam) { + $this->StreamParam = $StreamParam; + } + + /** + * 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"); + + $element->appendChild($doc->createTextNode($this->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..623d962 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); } From 8e99bad61d328c462d23476c6c91686f28fa88d1 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 15 Sep 2022 00:24:55 -0400 Subject: [PATCH 2/4] Update StreamParam.php --- src/Voice/Bxml/StreamParam.php | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/Voice/Bxml/StreamParam.php b/src/Voice/Bxml/StreamParam.php index 513f107..cafff17 100644 --- a/src/Voice/Bxml/StreamParam.php +++ b/src/Voice/Bxml/StreamParam.php @@ -2,7 +2,7 @@ /** * StreamParam.php * - * Implementation of the BXML StreamParam tag + * Implementation of the BXML StreamParam 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. * * * @copyright Bandwidth INC */ @@ -13,15 +13,6 @@ class StreamParam extends Verb { - /** - * Constructor for StreamParam - * - * @param string * 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. - */ - public function __construct($StreamParam) { - $this->StreamParam = $StreamParam; - } - /** * Sets the name attribute for StreamParam * @@ -43,8 +34,6 @@ public function value($value) { public function toBxml($doc) { $element = $doc->createElement("StreamParam"); - $element->appendChild($doc->createTextNode($this->StreamParam)); - if(isset($this->name)) { $element->setAttribute("name", $this->name); } From f54666706c35223a5104000a7023b78fec022b66 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 15 Sep 2022 00:40:22 -0400 Subject: [PATCH 3/4] Update StartStream.php --- src/Voice/Bxml/StartStream.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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; } } From 1a86eeb5896b1e08472a54e918a5f96b24e9adf6 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 15 Sep 2022 00:41:58 -0400 Subject: [PATCH 4/4] Update BxmlTest.php --- tests/BxmlTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/BxmlTest.php b/tests/BxmlTest.php index 623d962..d7d15f1 100644 --- a/tests/BxmlTest.php +++ b/tests/BxmlTest.php @@ -372,7 +372,7 @@ public function testStartStream() { $response = new BandwidthLib\Voice\Bxml\Response(); $response->addVerb($startStream); - $expectedXml = ''; + $expectedXml = ''; $responseXml = $response->toBxml(); $this->assertEquals($expectedXml, $responseXml); }