Skip to content

Commit 923e8ad

Browse files
authored
Tag & SipUri BXML (#13)
* Tag & SipUri BXML * removed comment * SipUri list * typo * SipUri value
1 parent 82d0ad2 commit 923e8ad

File tree

4 files changed

+186
-1
lines changed

4 files changed

+186
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ public class Response {
4343
@XmlElement(name = Bridge.TYPE_NAME, type = Bridge.class),
4444
@XmlElement(name = Ring.TYPE_NAME, type = Ring.class),
4545
@XmlElement(name = StartGather.TYPE_NAME, type = StartGather.class),
46-
@XmlElement(name = StopGather.TYPE_NAME, type = StopGather.class)
46+
@XmlElement(name = StopGather.TYPE_NAME, type = StopGather.class),
47+
@XmlElement(name = Tag.TYPE_NAME, type = Tag.class),
48+
@XmlElement(name = SipUri.TYPE_NAME, type = SipUri.class)
4749
})
4850
private final List<Verb> verbs = new ArrayList<>();
4951

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
2+
package com.bandwidth.voice.bxml.verbs;
3+
4+
import java.net.URI;
5+
import javax.xml.bind.annotation.XmlAttribute;
6+
import javax.xml.bind.annotation.XmlType;
7+
import javax.xml.bind.annotation.XmlValue;
8+
import lombok.Builder;
9+
10+
/**
11+
*/
12+
@Builder
13+
@XmlType(name = SipUri.TYPE_NAME)
14+
public class SipUri implements Verb {
15+
public static final String TYPE_NAME = "SipUri";
16+
17+
/**
18+
* SipUri to transfer to
19+
*/
20+
@XmlValue
21+
private String sipUri;
22+
23+
/**
24+
* (optional) The value of the User-To-User header to send within the initial INVITE. Must include the encoding parameter as specified in RFC 7433. Only base64 and jwt encoding are currently allowed. This value, including the encoding specifier, may not exceed 256 characters.
25+
*/
26+
@XmlAttribute
27+
private String uui;
28+
29+
/**
30+
* (optional) URL, if any, to send the Transfer Answer event to and request BXML to be executed for the called party before the call is bridged. May be a relative URL.
31+
*/
32+
@XmlAttribute
33+
private URI transferAnswerUrl;
34+
35+
/**
36+
* (optional) The HTTP method to use for the request to transferAnswerUrl. GET or POST. Default value is POST.
37+
*/
38+
@XmlAttribute
39+
private Method transferAnswerMethod;
40+
41+
/**
42+
* (optional) A fallback url which, if provided, will be used to retry the Transfer Answer callback delivery in case transferAnswerUrl fails to respond.
43+
*/
44+
@XmlAttribute
45+
private URI transferAnswerFallbackUrl;
46+
47+
/**
48+
* (optional) The HTTP method to use to deliver the Transfer Answer callback to transferAnswerFallbackUrl. GET or POST. Default value is POST.
49+
*/
50+
@XmlAttribute
51+
private Method transferAnswerFallbackMethod;
52+
53+
/**
54+
* (optional) URL, if any, to send the Transfer Disconnect event to. This event will be sent regardless of how the transfer ends and may not be responded to with BXML. May be a relative URL.
55+
*/
56+
@XmlAttribute
57+
private URI transferDisconnectUrl;
58+
59+
/**
60+
* (optional) The HTTP method to use for the request to transferDisconnectUrl. GET or POST. Default value is POST.
61+
*/
62+
@XmlAttribute
63+
private Method transferDisconnectMethod;
64+
65+
/**
66+
* (optional) The username to send in the HTTP request to transferAnswerUrl and transferDisconnectUrl.
67+
*/
68+
@XmlAttribute
69+
private String username;
70+
71+
/**
72+
* (optional) The password to send in the HTTP request to transferAnswerUrl and transferDisconnectUrl.
73+
*/
74+
@XmlAttribute
75+
private String password;
76+
77+
/**
78+
* (optional) The username to send in the HTTP request to transferAnswerFallbackUrl.
79+
*/
80+
@XmlAttribute
81+
private String fallbackUsername;
82+
83+
/**
84+
* (optional) The password to send in the HTTP request to transferAnswerFallbackUrl.
85+
*/
86+
@XmlAttribute
87+
private String fallbackPassword;
88+
89+
/**
90+
* (optional) A custom string that will be sent with these and all future callbacks unless overwritten by a future tag attribute or cleared.
91+
*
92+
* May be cleared by setting tag=""
93+
*
94+
* Max length 256 characters.
95+
*/
96+
@XmlAttribute
97+
private String tag;
98+
99+
public static class SipUriBuilder {
100+
101+
102+
public SipUri.SipUriBuilder transferAnswerUrl(URI uri){
103+
this.transferAnswerUrl = uri;
104+
return this;
105+
}
106+
107+
public SipUri.SipUriBuilder transferAnswerUrl(String uri){
108+
return transferAnswerUrl(URI.create(uri));
109+
}
110+
111+
public SipUri.SipUriBuilder transferAnswerMethod(Method method){
112+
this.transferAnswerMethod = method;
113+
return this;
114+
}
115+
116+
public SipUri.SipUriBuilder transferAnswerMethod(String method){
117+
return transferAnswerMethod(Method.fromValue(method));
118+
}
119+
120+
public SipUri.SipUriBuilder transferAnswerFallbackUrl(URI uri){
121+
this.transferAnswerFallbackUrl = uri;
122+
return this;
123+
}
124+
125+
public SipUri.SipUriBuilder transferAnswerFallbackUrl(String uri){
126+
return transferAnswerFallbackUrl(URI.create(uri));
127+
}
128+
129+
public SipUri.SipUriBuilder transferAnswerFallbackMethod(Method method){
130+
this.transferAnswerFallbackMethod = method;
131+
return this;
132+
}
133+
134+
public SipUri.SipUriBuilder transferAnswerFallbackMethod(String method){
135+
return transferAnswerFallbackMethod(Method.fromValue(method));
136+
}
137+
138+
public SipUri.SipUriBuilder transferDisconnectUrl(URI uri){
139+
this.transferDisconnectUrl = uri;
140+
return this;
141+
}
142+
143+
public SipUri.SipUriBuilder transferDisconnectUrl(String uri){
144+
return transferDisconnectUrl(URI.create(uri));
145+
}
146+
147+
public SipUri.SipUriBuilder transferDisconnectMethod(Method method){
148+
this.transferDisconnectMethod = method;
149+
return this;
150+
}
151+
152+
public SipUri.SipUriBuilder transferDisconnectMethod(String method){
153+
return transferDisconnectMethod(Method.fromValue(method));
154+
}
155+
}
156+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
package com.bandwidth.voice.bxml.verbs;
3+
4+
import javax.xml.bind.annotation.XmlType;
5+
import javax.xml.bind.annotation.XmlValue;
6+
import lombok.Builder;
7+
8+
/**
9+
* The Tag verb is used to set a new tag value without executing a callback. This new tag will be sent with all future callbacks unless overwritten by a future tag attribute or <Tag> verb, or cleared.
10+
*/
11+
@Builder
12+
@XmlType(name = Tag.TYPE_NAME)
13+
public class Tag implements Verb {
14+
public static final String TYPE_NAME = "Tag";
15+
16+
/**
17+
* The new tag value. Leading and trailing whitespace is trimmed. Leave blank to clear the tag.
18+
*/
19+
@XmlValue
20+
private String value;
21+
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ public class Transfer implements Verb {
2727
@XmlElement(name = PhoneNumber.TYPE_NAME)
2828
private final List<PhoneNumber> phoneNumbers;
2929

30+
/**
31+
* A collection of SipUris to transfer the call to. The first to answer will be transferred.
32+
*/
33+
@XmlElement(name = SipUri.TYPE_NAME)
34+
private final List<SipUri> sipUris;
35+
3036
/**
3137
* (optional) The caller ID to use when the call is transferred, if different. Must be in E.164 format (e.g. +15555555555).
3238
* <br/>

0 commit comments

Comments
 (0)