diff --git a/src/main/java/com/bandwidth/voice/bxml/verbs/Bxml.java b/src/main/java/com/bandwidth/voice/bxml/verbs/Bxml.java index 53bc5572..b76c76bf 100644 --- a/src/main/java/com/bandwidth/voice/bxml/verbs/Bxml.java +++ b/src/main/java/com/bandwidth/voice/bxml/verbs/Bxml.java @@ -47,7 +47,8 @@ public class Bxml { @XmlElement(name = Tag.TYPE_NAME, type = Tag.class), @XmlElement(name = SipUri.TYPE_NAME, type = SipUri.class), @XmlElement(name = StartStream.TYPE_NAME, type = StartStream.class), - @XmlElement(name = StopStream.TYPE_NAME, type = StopStream.class) + @XmlElement(name = StopStream.TYPE_NAME, type = StopStream.class), + @XmlElement(name = StreamParam.TYPE_NAME, type = StreamParam.class) }) private final List verbs = new ArrayList<>(); diff --git a/src/main/java/com/bandwidth/voice/bxml/verbs/StartStream.java b/src/main/java/com/bandwidth/voice/bxml/verbs/StartStream.java index 77e00894..e0422697 100644 --- a/src/main/java/com/bandwidth/voice/bxml/verbs/StartStream.java +++ b/src/main/java/com/bandwidth/voice/bxml/verbs/StartStream.java @@ -4,8 +4,14 @@ import lombok.Builder; import java.net.URI; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.XmlElement; + /** * The StartStream verb allows a segment of a call to be streamed to an external destination. @@ -15,6 +21,11 @@ public class StartStream implements Verb { public static final String TYPE_NAME = "StartStream"; + /** + * 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. + */ + @XmlElement(name = StreamParam.TYPE_NAME) + private final List streamParams; /** * (optional) A name to refer to this stream by. Used when sending [``][1]. If not provided, a random name will be generated and sent in the [`Media Stream Started`][2] webook. @@ -105,6 +116,22 @@ public StartStreamBuilder streamEventMethod(Method method){ public StartStreamBuilder streamEventMethod(String method){ return streamEventMethod(Method.fromValue(method)); } + + /** + * (optional) 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 StartStreamBuilder streamParams(StreamParam ... streamParams){ + this.streamParams = Arrays.asList(streamParams); + return this; + } + + /** + * (optional) 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 StartStreamBuilder streamParams(List streamParams){ + this.streamParams = streamParams; + return this; + } } } diff --git a/src/main/java/com/bandwidth/voice/bxml/verbs/StreamParam.java b/src/main/java/com/bandwidth/voice/bxml/verbs/StreamParam.java new file mode 100644 index 00000000..9f006a39 --- /dev/null +++ b/src/main/java/com/bandwidth/voice/bxml/verbs/StreamParam.java @@ -0,0 +1,29 @@ + +package com.bandwidth.voice.bxml.verbs; + +import lombok.Builder; + + +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlType; + +/** + * Object representation of a StreamParam + */ +@Builder +@XmlType(name = StreamParam.TYPE_NAME) +public class StreamParam { + public static final String TYPE_NAME = "StreamParam"; + + /** + * (required) The name of this parameter, up to 256 characters. + */ + @XmlAttribute + private String name; + + /** + * (required) The value of this parameter, up to 2048 characters. + */ + @XmlAttribute + private String value; +} diff --git a/src/test/java/com/bandwidth/BxmlTest.java b/src/test/java/com/bandwidth/BxmlTest.java index 7dda5a8c..f37ad6cf 100644 --- a/src/test/java/com/bandwidth/BxmlTest.java +++ b/src/test/java/com/bandwidth/BxmlTest.java @@ -454,6 +454,17 @@ public void testStopRecording() { @Test public void testStartStream() { + StreamParam streamParam1 = StreamParam.builder() + .name("name1") + .value("value1") + .build(); + StreamParam streamParam2 = StreamParam.builder() + .name("name2") + .value("value2") + .build(); + ArrayList streamParams = new ArrayList(); + streamParams.add(streamParam1); + streamParams.add(streamParam2); StartStream startStream = StartStream.builder() .destination("https://url.com") .streamEventMethod("POST") @@ -462,13 +473,14 @@ public void testStartStream() { .name("test") .tracks("inbound") .streamEventUrl("https://url.com") + .streamParams(streamParams) .build(); String response = new Response() .add(startStream) .toBXML(); - String expected = ""; + String expected = ""; assertEquals("BXML strings not equal", expected, response); }