11package 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+
37import javax .xml .bind .annotation .XmlAttribute ;
48import javax .xml .bind .annotation .XmlRootElement ;
59import javax .xml .bind .annotation .XmlValue ;
610import 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 ;
0 commit comments