Skip to content

Commit 90c11f2

Browse files
Merge pull request #74 from Bandwidth/DX-2859
Adding StreamParam for StartStream
2 parents 9d51390 + 81eda77 commit 90c11f2

File tree

4 files changed

+71
-2
lines changed

4 files changed

+71
-2
lines changed

src/main/java/com/bandwidth/voice/bxml/verbs/Bxml.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ public class Bxml {
4747
@XmlElement(name = Tag.TYPE_NAME, type = Tag.class),
4848
@XmlElement(name = SipUri.TYPE_NAME, type = SipUri.class),
4949
@XmlElement(name = StartStream.TYPE_NAME, type = StartStream.class),
50-
@XmlElement(name = StopStream.TYPE_NAME, type = StopStream.class)
50+
@XmlElement(name = StopStream.TYPE_NAME, type = StopStream.class),
51+
@XmlElement(name = StreamParam.TYPE_NAME, type = StreamParam.class)
5152
})
5253
private final List<Verb> verbs = new ArrayList<>();
5354

src/main/java/com/bandwidth/voice/bxml/verbs/StartStream.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,14 @@
44
import lombok.Builder;
55

66
import java.net.URI;
7+
import java.util.ArrayList;
8+
import java.util.Arrays;
9+
import java.util.List;
10+
711
import javax.xml.bind.annotation.XmlAttribute;
812
import javax.xml.bind.annotation.XmlType;
13+
import javax.xml.bind.annotation.XmlElement;
14+
915

1016
/**
1117
* The StartStream verb allows a segment of a call to be streamed to an external destination.
@@ -15,6 +21,11 @@
1521
public class StartStream implements Verb {
1622
public static final String TYPE_NAME = "StartStream";
1723

24+
/**
25+
* You may specify up to 12 <StreamParam/> elements nested within a <StartStream> tag. These elements define optional user specified parameters that will be sent to the destination URL when the stream is first started.
26+
*/
27+
@XmlElement(name = StreamParam.TYPE_NAME)
28+
private final List<StreamParam> streamParams;
1829

1930
/**
2031
* <i>(optional)</i> A name to refer to this stream by. Used when sending [`<StopStream>`][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){
105116
public StartStreamBuilder streamEventMethod(String method){
106117
return streamEventMethod(Method.fromValue(method));
107118
}
119+
120+
/**
121+
* <i>(optional)</i> You may specify up to 12 <StreamParam/> elements nested within a <StartStream> tag. These elements define optional user specified parameters that will be sent to the destination URL when the stream is first started.
122+
*/
123+
public StartStreamBuilder streamParams(StreamParam ... streamParams){
124+
this.streamParams = Arrays.asList(streamParams);
125+
return this;
126+
}
127+
128+
/**
129+
* <i>(optional)</i> You may specify up to 12 <StreamParam/> elements nested within a <StartStream> tag. These elements define optional user specified parameters that will be sent to the destination URL when the stream is first started.
130+
*/
131+
public StartStreamBuilder streamParams(List<StreamParam> streamParams){
132+
this.streamParams = streamParams;
133+
return this;
134+
}
108135
}
109136

110137
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
package com.bandwidth.voice.bxml.verbs;
3+
4+
import lombok.Builder;
5+
6+
7+
import javax.xml.bind.annotation.XmlAttribute;
8+
import javax.xml.bind.annotation.XmlType;
9+
10+
/**
11+
* Object representation of a StreamParam
12+
*/
13+
@Builder
14+
@XmlType(name = StreamParam.TYPE_NAME)
15+
public class StreamParam {
16+
public static final String TYPE_NAME = "StreamParam";
17+
18+
/**
19+
* <i>(required)</i> The name of this parameter, up to 256 characters.
20+
*/
21+
@XmlAttribute
22+
private String name;
23+
24+
/**
25+
* <i>(required)</i> The value of this parameter, up to 2048 characters.
26+
*/
27+
@XmlAttribute
28+
private String value;
29+
}

src/test/java/com/bandwidth/BxmlTest.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,17 @@ public void testStopRecording() {
454454

455455
@Test
456456
public void testStartStream() {
457+
StreamParam streamParam1 = StreamParam.builder()
458+
.name("name1")
459+
.value("value1")
460+
.build();
461+
StreamParam streamParam2 = StreamParam.builder()
462+
.name("name2")
463+
.value("value2")
464+
.build();
465+
ArrayList<StreamParam> streamParams = new ArrayList<StreamParam>();
466+
streamParams.add(streamParam1);
467+
streamParams.add(streamParam2);
457468
StartStream startStream = StartStream.builder()
458469
.destination("https://url.com")
459470
.streamEventMethod("POST")
@@ -462,13 +473,14 @@ public void testStartStream() {
462473
.name("test")
463474
.tracks("inbound")
464475
.streamEventUrl("https://url.com")
476+
.streamParams(streamParams)
465477
.build();
466478

467479
String response = new Response()
468480
.add(startStream)
469481
.toBXML();
470482

471-
String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response><StartStream name=\"test\" tracks=\"inbound\" destination=\"https://url.com\" streamEventUrl=\"https://url.com\" streamEventMethod=\"POST\" username=\"user\" password=\"pass\"/></Response>";
483+
String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response><StartStream name=\"test\" tracks=\"inbound\" destination=\"https://url.com\" streamEventUrl=\"https://url.com\" streamEventMethod=\"POST\" username=\"user\" password=\"pass\"><StreamParam name=\"name1\" value=\"value1\"/><StreamParam name=\"name2\" value=\"value2\"/></StartStream></Response>";
472484

473485
assertEquals("BXML strings not equal", expected, response);
474486
}

0 commit comments

Comments
 (0)