Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/main/java/com/bandwidth/sdk/model/bxml/Connect.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
*
* @param endpoints (list[Endpoint], optional): List of endpoints to connect the call to.
* @param eventCallbackUrl (str, optional): URL to send events to during the connection lifecycle. May be a relative URL.
* @param eventFallbackUrl (str, optional): A fallback url which, if provided, will be used to retry the event callback delivery in case eventCallbackUrl fails to respond.
*
*/
public class Connect implements Verb {
Expand All @@ -40,6 +41,9 @@ public class Connect implements Verb {
@XmlAttribute
protected URI eventCallbackUrl;

@XmlAttribute
protected URI eventFallbackUrl;

@Override
public String getVerbName() {
return TYPE_NAME;
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/com/bandwidth/sdk/model/bxml/Forward.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
* @param uui (str, optional): The value of the User-To-User header to send within the outbound INVITE when forwarding to a SIP URI.
* 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.
* @param privacy (bool, optional): A boolean value to indicate that the calling number should be hidden. Use callerDisplayName to customize the name shown to the recipient. Default is false.
* @param callerDisplayName (str, optional): The caller display name to use when the call is created. May not exceed 256 characters nor contain control characters such as new lines.
* If privacy is true, only the values Restricted, Anonymous, Private, or Unavailable are valid.
*/
public class Forward implements Verb {

Expand All @@ -79,6 +82,12 @@ public class Forward implements Verb {
@Builder.Default
private DiversionReason diversionReason = DiversionReason.unknown;

@XmlAttribute
private Boolean privacy;

@XmlAttribute
private String callerDisplayName;

@Override
public String getVerbName() {
return TYPE_NAME;
Expand Down
32 changes: 32 additions & 0 deletions src/main/java/com/bandwidth/sdk/model/bxml/Gather.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@
* Default value is 5. Range: decimal values between 0 - 60.
* @param repeatCount (int, optional): The number of times the audio prompt should be played if no digits are pressed. For example, if this value is 3, the nested audio clip will be played a maximum of three times.
* The delay between repetitions will be equal to first_digit_timeout. Default value is 1. repeat_count * number of verbs must not be greater than 20.
* @param input (str, optional): The input mode to collect from the caller: dtmf, speech, or dtmf_speech. Default value is dtmf.
* @param hints (str, optional): Words or phrases that improve speech recognition accuracy. Only used when input includes speech.
* @param language (str, optional): The language code to use for speech recognition. Only used when input includes speech.
* @param partialResultCallback (str, optional): URL to send the Partial Result event to as speech is recognized. May be a relative URL. Only used when input includes speech.
* @param partialResultCallbackMethod (str, optional): The HTTP method to use for the request to partialResultCallback. GET or POST. Default value is POST.
* @param profanityFilter (bool, optional): Whether profane words are filtered out of the transcription. Default value is true. Only used when input includes speech.
* @param speechModel (str, optional): The speech recognition model to use. Only used when input includes speech.
* @param speechTimeout (int, optional): Time (in seconds) to wait for speech input before terminating the Gather. Default value is 5.
*
* Nested Verbs:
* @param PlayAudio: (optional) Using the PlayAudio inside the Gather verb will play the media until a digit is received.
Expand Down Expand Up @@ -116,6 +124,30 @@ public class Gather implements Verb {
@Default
protected int repeatCount = DEFAULT_REPEAT_COUNT;

@XmlAttribute
protected String input;

@XmlAttribute
protected String hints;

@XmlAttribute
protected String language;

@XmlAttribute
protected String partialResultCallback;

@XmlAttribute
protected String partialResultCallbackMethod;

@XmlAttribute
protected Boolean profanityFilter;

@XmlAttribute
protected String speechModel;

@XmlAttribute
protected Integer speechTimeout;

@Override
public String getVerbName() {
return TYPE_NAME;
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/com/bandwidth/sdk/model/bxml/Record.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
* @param recordingAvailableUrl (str, optional): URL to send the Recording Available event to once it has been processed. Does not accept BXML. May be a relative URL. Defaults to None.
* @param recordingAvailableMethod (str, optional): The HTTP method to use for the request to recordingAvailableUrl. GET or POST. Default value is POST. Defaults to None.
* @param transcribe (str, optional): A boolean value to indicate that recording should be transcribed. Transcription can succeed only for recordings of length greater than 500 milliseconds and less than 4 hours. Default is false. Defaults to None.
* @param detectLanguage (bool, optional): A boolean value to indicate that the transcription service should detect the dominant language of the recording rather than assuming English. Ignored unless transcribe is true. Default is false.
* @param transcriptionAvailableUrl (str, optional): URL to send the Transcription Available event to once it has been processed. Does not accept BXML. May be a relative URL. Defaults to None.
* @param transcriptionAvailableMethod (str, optional): The HTTP method to use for the request to transcriptionAvailableUrl. GET or POST. Default value is POST. Defaults to None.
* @param username (str, optional): The username to send in the HTTP request to recordCompleteUrl, recordingAvailableUrl or transcriptionAvailableUrl. If specified, the URLs must be TLS-encrypted (i.e., https). Defaults to None.
Expand All @@ -49,6 +50,7 @@
* @param maxDuration (int, optional): Maximum length of recording (in seconds). Max 10800 (3 hours). Default value is 60. Defaults to None.
* @param silenceTimeout (str, optional): Length of silence after which to end the recording (in seconds). Max is equivalent to the maximum maxDuration value. Default value is 0, which means no timeout. Defaults to None.
* @param fileFormat (str, optional): The audio format that the recording will be saved as: mp3 or wav. Default value is wav. Defaults to None.
* @param recordingName (str, optional): A name identifying this recording, returned in the Recording Available event.
*
*/
public class Record implements TranscriptionProducer {
Expand Down Expand Up @@ -94,6 +96,9 @@ public class Record implements TranscriptionProducer {
@XmlAttribute
protected Boolean transcribe;

@XmlAttribute
protected Boolean detectLanguage;

@XmlAttribute
@Default
protected Double silenceTimeout = DEFAULT_RECORD_SILENCE_TIMEOUT;
Expand All @@ -116,6 +121,9 @@ public class Record implements TranscriptionProducer {
@XmlAttribute
protected String fallbackPassword;

@XmlAttribute
protected String recordingName;

@Override
public String getVerbName() {
return TYPE_NAME;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@
* @param recordingAvailableUrl (str, optional): URL to send the Recording Available event to once it has been processed. Does not accept BXML. May be a relative URL. Defaults to None.
* @param recordingAvailableMethod (str, optional): The HTTP method to use for the request to recordingAvailableUrl. GET or POST. Default value is POST.
* @param transcribe (str, optional): A boolean value to indicate that recording should be transcribed. Transcription can succeed only for recordings of length greater than 500 milliseconds and less than 4 hours. Default is false. Defaults to None.
* @param detectLanguage (bool, optional): A boolean value to indicate that the transcription service should detect the dominant language of the recording rather than assuming English. Ignored unless transcribe is true. Default is false.
* @param transcriptionAvailableUrl (str, optional): URL to send the Transcription Available event to once it has been processed. Does not accept BXML. May be a relative URL. Defaults to None.
* @param transcriptionAvailableMethod (str, optional): The HTTP method to use for the request to transcriptionAvailableUrl. GET or POST. Default value is POST. Defaults to None.
* @param username (str, optional): The username to send in the HTTP request to recordCompleteUrl, recordingAvailableUrl or transcriptionAvailableUrl. If specified, the URLs must be TLS-encrypted (i.e., https). Defaults to None.
* @param password (str, optional): The password to send in the HTTP request to recordCompleteUrl, recordingAvailableUrl or transcriptionAvailableUrl. If specified, the URLs must be TLS-encrypted (i.e., https). Defaults to None.
* @param tag (str, optional): A custom string that will be sent with this and all future callbacks unless overwritten by a future tag attribute or <Tag> verb, or cleared. May be cleared by setting tag="". Max length 256 characters. Defaults to None.
* @param fileFormat (str, optional): The audio format that the recording will be saved as: mp3 or wav. Default value is wav. Defaults to None. max_duration (str, optional): Maximum length of recording (in seconds). Max 10800 (3 hours). Default value is 60. Defaults to None.
* @param multiChannel (str, optional): A boolean value indicating whether or not the recording file should separate each side of the call into its own audio channel. Default value is false.
* @param recordingName (str, optional): A name identifying this recording, returned in the Recording Available event.
*
*/
public class StartRecording implements TranscriptionProducer {
Expand All @@ -53,6 +55,9 @@ public class StartRecording implements TranscriptionProducer {
@XmlAttribute
protected Boolean transcribe;

@XmlAttribute
protected Boolean detectLanguage;

@XmlAttribute
protected String transcriptionAvailableUrl;

Expand All @@ -76,6 +81,9 @@ public class StartRecording implements TranscriptionProducer {
@Default
protected Boolean multiChannel = false;

@XmlAttribute
protected String recordingName;

@Override
public String getVerbName() {
return TYPE_NAME;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
* @param username (str, optional): The username to send in the HTTP request to transcriptionEventUrl. If specified, the URLs must be TLS-encrypted (i.e., https).
* @param password (str, optional): The password to send in the HTTP request to transcriptionEventUrl. If specified, the URLs must be TLS-encrypted (i.e., https).
* @param stabilized (str, optional): Whether to send transcription update events to the specified destination only after they have become stable. Requires destination. Defaults to true.
* @param detectLanguage (bool, optional): Whether to detect the dominant language being spoken rather than assuming English. Default is false.
* @param preferredLanguages (str, optional): A comma-separated list of language locales to transcribe in, for example "en-US,es-US". Requires detectLanguage to be false, and accepts only one dialect per language. Defaults to en-US.
*
* Nested Verbs:
* @param CustomParam: (optional) You may specify up to 12 <CustomParam/> elements nested within a <StartTranscription> tag.
Expand Down Expand Up @@ -78,6 +80,12 @@ public class StartTranscription implements Verb {
@Default
protected Boolean stabilized = true;

@XmlAttribute
protected Boolean detectLanguage;

@XmlAttribute
protected String preferredLanguages;

@XmlElements({
@XmlElement(name = CustomParam.TYPE_NAME, type = CustomParam.class)
})
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/bandwidth/sdk/model/bxml/Transfer.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
*
* This parameter is considered only when diversionTreatment is set to stack. Defaults is unknown.
* Defaults to None.
* @param privacy (bool, optional): A boolean value to indicate that the calling number should be hidden. Use transferCallerDisplayName to customize the name shown to the recipient. Default is false.
*
*/
public class Transfer implements Verb {
Expand Down Expand Up @@ -128,6 +129,9 @@ public class Transfer implements Verb {
@Default
protected DiversionReason diversionReason = DiversionReason.unknown;

@XmlAttribute
protected Boolean privacy;

@Override
public String getVerbName() {
return TYPE_NAME;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class ConnectVerbTest {
Connect connectWithCallback = Connect.builder()
.endpoints(List.of(endpoint))
.eventCallbackUrl(URI.create("https://example.com/callback"))
.eventFallbackUrl(URI.create("https://example.com/fallback"))
.build();

Connect connectWithoutCallback = Connect.builder()
Expand All @@ -40,7 +41,7 @@ public class ConnectVerbTest {
@Test
public void connectVerbWithCallbackWorks() throws JAXBException {
JAXBContext jaxbContext = JAXBContext.newInstance(Bxml.class);
String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Bxml><Connect eventCallbackUrl=\"https://example.com/callback\"><Endpoint>test-endpoint-id</Endpoint></Connect></Bxml>";
String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Bxml><Connect eventCallbackUrl=\"https://example.com/callback\" eventFallbackUrl=\"https://example.com/fallback\"><Endpoint>test-endpoint-id</Endpoint></Connect></Bxml>";

assertThat(new Bxml().with(connectWithCallback).toBxml(jaxbContext), is(expected));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@ public class ForwardVerbTest {
.diversionTreatment(DiversionTreatment.propagate)
.diversionReason(DiversionReason.away)
.uui("93d6f3c0be5845960b744fa28015d8ede84bd1a4;encoding=base64,asdf;encoding=jwt")
.privacy(true)
.callerDisplayName("Restricted")
.build();

@Test
public void forwardVerbWorks() throws JAXBException {
JAXBContext jaxbContext = JAXBContext.newInstance(Bxml.class);
String expectedBxml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Bxml><Forward to=\"+19195554321\" from=\"19195554322\" uui=\"93d6f3c0be5845960b744fa28015d8ede84bd1a4;encoding=base64,asdf;encoding=jwt\" callTimeout=\"15.0\" diversionTreatment=\"propagate\" diversionReason=\"away\"/></Bxml>";
String expectedBxml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Bxml><Forward to=\"+19195554321\" from=\"19195554322\" uui=\"93d6f3c0be5845960b744fa28015d8ede84bd1a4;encoding=base64,asdf;encoding=jwt\" callTimeout=\"15.0\" diversionTreatment=\"propagate\" diversionReason=\"away\" privacy=\"true\" callerDisplayName=\"Restricted\"/></Bxml>";

assertThat(new Bxml().with(forward).toBxml(jaxbContext), is(expectedBxml));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,21 @@ public class GatherVerbTest {
.interDigitTimeout(1d)
.firstDigitTimeout(3d)
.repeatCount(2)
.input("dtmf_speech")
.hints("yes | no | maybe")
.language("en-US")
.partialResultCallback("partial-test.com")
.partialResultCallbackMethod("POST")
.profanityFilter(true)
.speechModel("default")
.speechTimeout(10)
.children(List.of(playAudio, speakSentence))
.build();

@Test
public void gatherVerbWorks() throws JAXBException {
JAXBContext jaxbContext = JAXBContext.newInstance(Bxml.class);
String expectedBxml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Bxml><Gather gatherUrl=\"test.com\" gatherFallbackUrl=\"fallback-test.com\" gatherMethod=\"POST\" gatherFallbackMethod=\"GET\" username=\"user\" password=\"pass\" fallbackUsername=\"user\" fallbackPassword=\"pass\" tag=\"tag\" terminatingDigits=\"2\" maxDigits=\"5\" firstDigitTimeout=\"3.0\" interDigitTimeout=\"1.0\" repeatCount=\"2\"><PlayAudio>test.com</PlayAudio><SpeakSentence gender=\"female\" locale=\"en_US\">Hello. Your number is &lt;say-as interpret-as=\"telephone\"&gt;asdf&lt;/say-as&gt;, lets play a game. What is 10 + 3. Press the pound key when finished.</SpeakSentence></Gather></Bxml>";
String expectedBxml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Bxml><Gather gatherUrl=\"test.com\" gatherFallbackUrl=\"fallback-test.com\" gatherMethod=\"POST\" gatherFallbackMethod=\"GET\" username=\"user\" password=\"pass\" fallbackUsername=\"user\" fallbackPassword=\"pass\" tag=\"tag\" terminatingDigits=\"2\" maxDigits=\"5\" firstDigitTimeout=\"3.0\" interDigitTimeout=\"1.0\" repeatCount=\"2\" input=\"dtmf_speech\" hints=\"yes | no | maybe\" language=\"en-US\" partialResultCallback=\"partial-test.com\" partialResultCallbackMethod=\"POST\" profanityFilter=\"true\" speechModel=\"default\" speechTimeout=\"10\"><PlayAudio>test.com</PlayAudio><SpeakSentence gender=\"female\" locale=\"en_US\">Hello. Your number is &lt;say-as interpret-as=\"telephone\"&gt;asdf&lt;/say-as&gt;, lets play a game. What is 10 + 3. Press the pound key when finished.</SpeakSentence></Gather></Bxml>";

assertThat(new Bxml().with(gather).toBxml(jaxbContext), is(expectedBxml));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@ public class RecordVerbTest {
*/
Record record = Record.builder()
.maxDuration(10)
.transcribe(true)
.detectLanguage(true)
.recordingName("test-recording")
.build();

@Test
public void recordVerbWorks() throws JAXBException {
JAXBContext jaxbContext = JAXBContext.newInstance(Bxml.class);
String expectedBxml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Bxml><Record recordCompleteMethod=\"POST\" recordCompleteFallbackMethod=\"POST\" terminatingDigits=\"#\" maxDuration=\"10\" fileFormat=\"wav\" recordingAvailableMethod=\"POST\" silenceTimeout=\"0.0\"/></Bxml>";
String expectedBxml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Bxml><Record recordCompleteMethod=\"POST\" recordCompleteFallbackMethod=\"POST\" terminatingDigits=\"#\" maxDuration=\"10\" fileFormat=\"wav\" recordingAvailableMethod=\"POST\" transcribe=\"true\" detectLanguage=\"true\" silenceTimeout=\"0.0\" recordingName=\"test-recording\"/></Bxml>";

assertThat(new Bxml().with(record).toBxml(jaxbContext), is(expectedBxml));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ public class StartRecordingVerbTest {
.tag("tag")
.fileFormat("wav")
.multiChannel(true)
.detectLanguage(true)
.recordingName("test-recording")
.build();

@Test
public void startRecordingVerbWorks() throws JAXBException {
JAXBContext jaxbContext = JAXBContext.newInstance(Bxml.class);
String expectedBxml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Bxml><StartRecording recordingAvailableUrl=\"https://example.com\" recordingAvailableMethod=\"POST\" transcribe=\"true\" transcriptionAvailableUrl=\"transcription-example.com\" username=\"user\" password=\"pass\" tag=\"tag\" fileFormat=\"wav\" multiChannel=\"true\"/></Bxml>";
String expectedBxml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Bxml><StartRecording recordingAvailableUrl=\"https://example.com\" recordingAvailableMethod=\"POST\" transcribe=\"true\" detectLanguage=\"true\" transcriptionAvailableUrl=\"transcription-example.com\" username=\"user\" password=\"pass\" tag=\"tag\" fileFormat=\"wav\" multiChannel=\"true\" recordingName=\"test-recording\"/></Bxml>";

assertThat(new Bxml().with(startRecording).toBxml(jaxbContext), is(expectedBxml));
}
Expand Down
Loading