Skip to content

Commit 5d1f6c5

Browse files
committed
Update TwiML to reflect current docs
1 parent a3145b6 commit 5d1f6c5

File tree

3 files changed

+114
-2
lines changed

3 files changed

+114
-2
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<packaging>jar</packaging>
99
<name>twilio</name>
1010
<version>7.0.1-SNAPSHOT</version>
11-
<description>Release Candidate for Next-Gen Twilio Java Helper Library</description>
11+
<description>Twilio Java Helper Library</description>
1212
<url>https://www.twilio.com</url>
1313
<licenses>
1414
<license>

src/main/java/com/twilio/twiml/Conference.java

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
package com.twilio.twiml;
22

3+
import com.google.common.base.Function;
4+
import com.google.common.base.Joiner;
5+
import com.google.common.collect.Lists;
6+
37
import javax.xml.bind.annotation.XmlAttribute;
48
import javax.xml.bind.annotation.XmlRootElement;
59
import javax.xml.bind.annotation.XmlValue;
610
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
11+
import java.util.List;
712

813
/**
914
* TwiML wrapper for @see https://www.twilio.com/docs/api/twiml/conference.
@@ -45,6 +50,33 @@ public String toString() {
4550
}
4651
}
4752

53+
public enum ConferenceEvent {
54+
START("start"),
55+
END("end"),
56+
JOIN("join"),
57+
LEAVE("leave"),
58+
MUTE("mute"),
59+
HOLD("hold");
60+
61+
private final String value;
62+
63+
ConferenceEvent(String value) {
64+
this.value = value;
65+
}
66+
67+
@Override
68+
public String toString() {
69+
return this.value;
70+
}
71+
72+
public static final Function<ConferenceEvent, String> TO_STRING = new Function<ConferenceEvent, String>() {
73+
@Override
74+
public String apply(ConferenceEvent event) {
75+
return event.toString();
76+
}
77+
};
78+
}
79+
4880
@XmlAttribute
4981
private final Boolean muted;
5082

@@ -78,9 +110,20 @@ public String toString() {
78110
@XmlAttribute
79111
private final String eventCallbackUrl;
80112

113+
@XmlAttribute
114+
private final String statusCallbackEvent;
115+
116+
@XmlAttribute
117+
private final Method statusCallbackMethod;
118+
119+
@XmlAttribute
120+
private final String statusCallback;
121+
81122
@XmlValue
82123
private final String name;
83124

125+
private final List<ConferenceEvent> statusCallbackEvents;
126+
84127
// For XML Serialization
85128
private Conference() {
86129
this(new Builder(null));
@@ -98,6 +141,15 @@ private Conference(Builder b) {
98141
this.waitUrl = b.waitUrl;
99142
this.eventCallbackUrl = b.eventCallbackUrl;
100143
this.name = b.name;
144+
this.statusCallbackEvents = b.statusCallbackEvents;
145+
this.statusCallbackMethod = b.statusCallbackMethod;
146+
this.statusCallback = b.statusCallback;
147+
148+
if (this.statusCallbackEvents != null) {
149+
this.statusCallbackEvent = Joiner.on(" ").join(Lists.transform(this.statusCallbackEvents, ConferenceEvent.TO_STRING));
150+
} else {
151+
this.statusCallbackEvent = null;
152+
}
101153
}
102154

103155
public Boolean isMuted() {
@@ -140,6 +192,18 @@ public String getEventCallbackUrl() {
140192
return eventCallbackUrl;
141193
}
142194

195+
public Method getStatusCallbackMethod() {
196+
return statusCallbackMethod;
197+
}
198+
199+
public String getStatusCallback() {
200+
return statusCallback;
201+
}
202+
203+
public List<ConferenceEvent> getStatusCallbackEvents() {
204+
return statusCallbackEvents;
205+
}
206+
143207
public String getName() {
144208
return name;
145209
}
@@ -155,6 +219,9 @@ public static class Builder {
155219
private Method waitMethod;
156220
private String waitUrl;
157221
private String eventCallbackUrl;
222+
private List<ConferenceEvent> statusCallbackEvents;
223+
private Method statusCallbackMethod;
224+
private String statusCallback;
158225
private String name;
159226

160227
public Builder(String name) {
@@ -206,6 +273,21 @@ public Builder waitUrl(String waitUrl) {
206273
return this;
207274
}
208275

276+
public Builder statusCallbackEvents(List<ConferenceEvent> statusCallbackEvents) {
277+
this.statusCallbackEvents = statusCallbackEvents;
278+
return this;
279+
}
280+
281+
public Builder statusCallback(String statusCallback) {
282+
this.statusCallback = statusCallback;
283+
return this;
284+
}
285+
286+
public Builder statusCallbackMethod(Method statusCallbackMethod) {
287+
this.statusCallbackMethod = statusCallbackMethod;
288+
return this;
289+
}
290+
209291
public Builder eventCallbackUrl(String eventCallbackUrl) {
210292
this.eventCallbackUrl = eventCallbackUrl;
211293
return this;

src/main/java/com/twilio/twiml/Dial.java

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ public class Dial extends TwiML {
1818
public enum Record {
1919
DO_NOT_RECORD("do-not-record"),
2020
RECORD_FROM_RINGING("record-from-ringing"),
21-
RECORD_FROM_ANSWER("record-from-answer");
21+
RECORD_FROM_ANSWER("record-from-answer"),
22+
RECORD_FROM_ANSWER_DUAL("record-from-answer-dual"),
23+
RECORD_FROM_RINGING_DUAL("record-from-ringing-dual");
2224

2325
private final String value;
2426

@@ -66,6 +68,12 @@ public String toString() {
6668
@XmlAttribute
6769
private final String callerId;
6870

71+
@XmlAttribute
72+
private final String recordingStatusCallback;
73+
74+
@XmlAttribute
75+
private final Method recordingStatusCallbackMethod;
76+
6977
@XmlAttribute
7078
@XmlJavaTypeAdapter(TwiML.ToStringAdapter.class)
7179
private final Record record;
@@ -107,6 +115,8 @@ private Dial(Builder b) {
107115
this.action = b.action;
108116
this.method = b.method;
109117
this.callerId = b.callerId;
118+
this.recordingStatusCallback = b.recordingStatusCallback;
119+
this.recordingStatusCallbackMethod = b.recordingStatusCallbackMethod;
110120
this.record = b.record;
111121
this.trim = b.trim;
112122
this.numbers = Lists.newArrayList(b.numbers);
@@ -140,6 +150,14 @@ public String getCallerId() {
140150
return callerId;
141151
}
142152

153+
public String getRecordingStatusCallback() {
154+
return recordingStatusCallback;
155+
}
156+
157+
public Method getRecordingStatusCallbackMethod() {
158+
return recordingStatusCallbackMethod;
159+
}
160+
143161
public Record getRecord() {
144162
return record;
145163
}
@@ -175,6 +193,8 @@ public static class Builder {
175193
private String action;
176194
private Method method;
177195
private String callerId;
196+
private String recordingStatusCallback;
197+
private Method recordingStatusCallbackMethod;
178198
private Record record;
179199
private Trim trim;
180200
private List<Number> numbers = Lists.newArrayList();
@@ -213,6 +233,16 @@ public Builder callerId(String callerId) {
213233
return this;
214234
}
215235

236+
public Builder recordingStatusCallback(String recordingStatusCallback) {
237+
this.recordingStatusCallback = recordingStatusCallback;
238+
return this;
239+
}
240+
241+
public Builder recordingStatusCallbackMethod(Method recordingStatusCallbackMethod) {
242+
this.recordingStatusCallbackMethod = recordingStatusCallbackMethod;
243+
return this;
244+
}
245+
216246
public Builder trim(Trim trim) {
217247
this.trim = trim;
218248
return this;

0 commit comments

Comments
 (0)