11package com .twilio .twiml ;
22
33import com .google .common .collect .Lists ;
4+ import com .google .common .collect .Maps ;
45
5- import javax .xml .bind .annotation .XmlAttribute ;
6- import javax .xml .bind .annotation .XmlElement ;
7- import javax .xml .bind .annotation .XmlElements ;
8- import javax .xml .bind .annotation .XmlRootElement ;
6+ import javax .xml .bind .annotation .*;
97import javax .xml .bind .annotation .adapters .XmlJavaTypeAdapter ;
8+ import javax .xml .namespace .QName ;
9+ import java .util .HashMap ;
1010import java .util .List ;
11+ import java .util .Map ;
12+ import java .util .Set ;
1113
1214/**
1315 * TwiML wrapper for @see https://www.twilio.com/docs/api/twiml/dial.
@@ -84,13 +86,13 @@ public String toString() {
8486
8587 @ SuppressWarnings ("checkstyle:indentation" )
8688 @ XmlElements ({
87- @ XmlElement (name = "Number" , type = Number .class )
89+ @ XmlElement (name = "Number" , type = Number .class )
8890 })
8991 private final List <Number > numbers ;
9092
9193 @ SuppressWarnings ("checkstyle:indentation" )
9294 @ XmlElements ({
93- @ XmlElement (name = "Client" , type = Client .class )
95+ @ XmlElement (name = "Client" , type = Client .class )
9496 })
9597 private final List <Client > clients ;
9698
@@ -103,6 +105,9 @@ public String toString() {
103105 @ XmlElement (name = "Sip" )
104106 private final Sip sip ;
105107
108+ @ XmlAnyAttribute
109+ private Map <QName , String > options ;
110+
106111 // For XML Serialization
107112 private Dial () {
108113 this (new Builder ());
@@ -124,6 +129,7 @@ private Dial(Builder b) {
124129 this .conference = b .conference ;
125130 this .queue = b .queue ;
126131 this .sip = b .sip ;
132+ this .options = Maps .newHashMap (b .options );
127133 }
128134
129135 public Boolean isHangupOnStar () {
@@ -186,6 +192,16 @@ public Sip getSip() {
186192 return sip ;
187193 }
188194
195+ public Map <String , String > getOptions () {
196+ Map <String , String > convertedMap = new HashMap <>();
197+
198+ Set <QName > keys = options .keySet ();
199+ for (QName key : keys ) {
200+ convertedMap .put (key .getNamespaceURI (), options .get (key ));
201+ }
202+ return convertedMap ;
203+ }
204+
189205 public static class Builder {
190206 private Boolean hangupOnStar ;
191207 private Integer timeout ;
@@ -202,6 +218,7 @@ public static class Builder {
202218 private Conference conference ;
203219 private Queue queue ;
204220 private Sip sip ;
221+ private Map <QName , String > options = Maps .newHashMap ();
205222
206223 public Builder hangupOnStar (boolean hangupOnStar ) {
207224 this .hangupOnStar = hangupOnStar ;
@@ -278,6 +295,11 @@ public Builder sip(Sip sip) {
278295 return this ;
279296 }
280297
298+ public Builder options (String key , String value ) {
299+ this .options .put (new QName (key ), value );
300+ return this ;
301+ }
302+
281303 public Dial build () {
282304 return new Dial (this );
283305 }
0 commit comments