-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat (DEVEXP-148): Support Callouts (Custom)
- Loading branch information
Showing
15 changed files
with
387 additions
and
8 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
client/src/main/com/sinch/sdk/domains/sms/models/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** | ||
* SMS API related models | ||
* | ||
* @since 1.0 | ||
*/ | ||
package com.sinch.sdk.domains.sms.models; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
client/src/main/com/sinch/sdk/domains/voice/models/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** | ||
* Voice API related models | ||
* | ||
* @since 1.0 | ||
*/ | ||
package com.sinch.sdk.domains.voice.models; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
157 changes: 157 additions & 0 deletions
157
.../src/main/com/sinch/sdk/domains/voice/models/requests/CalloutRequestParametersCustom.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
package com.sinch.sdk.domains.voice.models.requests; | ||
|
||
import com.sinch.sdk.domains.voice.models.CalloutMethodType; | ||
import com.sinch.sdk.models.E164PhoneNumber; | ||
import java.util.Optional; | ||
|
||
/** | ||
* The custom callout, the server initiates a call from the servers that can be controlled by | ||
* specifying how the call should progress at each call event. | ||
*/ | ||
public class CalloutRequestParametersCustom extends CalloutRequestParameters { | ||
|
||
private final Integer maxDuration; | ||
private final String ice; | ||
private final String ace; | ||
private final String pie; | ||
|
||
public CalloutRequestParametersCustom( | ||
Destination destination, | ||
E164PhoneNumber cli, | ||
String dtfm, | ||
String custom, | ||
Integer maxDuration, | ||
String ice, | ||
String ace, | ||
String pie) { | ||
super(CalloutMethodType.CUSTOM_CALLOUT, destination, cli, dtfm, custom); | ||
|
||
this.maxDuration = maxDuration; | ||
this.ice = ice; | ||
this.ace = ace; | ||
this.pie = pie; | ||
} | ||
|
||
/** | ||
* The maximum amount of time in seconds that the call will last. | ||
* | ||
* @return Max duration value | ||
*/ | ||
public Optional<Integer> getMaxDuration() { | ||
return Optional.ofNullable(maxDuration); | ||
} | ||
|
||
/** | ||
* You can use inline <a | ||
* href="https://developers.sinch.com/docs/voice/api-reference/svaml/">SVAML</a> to replace a | ||
* callback URL when using custom callouts. | ||
* | ||
* <p>Ensure that the JSON object is escaped correctly | ||
* | ||
* <p>If inline ICE SVAML is passed, exclude cli and destination properties from the customCallout | ||
* request body. <b>Example:</b> <code> | ||
* "{\"action\": {\"name\": \"RunMenu\",\"locale\": \"en-US\",\"menus\": [{\"id\": \"main\",\"mainPrompt\": \"#tts[ Welcome to the main menu. Press 1 for a callback or 2 for a cancel<\/speak>]\",\"timeoutMills\": 5000,\"options\": [ {\"dtmf\": \"1\",\"action\": \"return(callback)\"}, {\"dtmf\": \"2\",\"action\": \"return(cancel)\"}]}]}}"" | ||
* </code> | ||
* | ||
* @return The Incoming Call Event value | ||
*/ | ||
public Optional<String> getIce() { | ||
return Optional.ofNullable(ice); | ||
} | ||
|
||
/** | ||
* You can use inline <a | ||
* href="https://developers.sinch.com/docs/voice/api-reference/svaml/">SVAML</a> to replace a | ||
* callback URL when using custom callouts. | ||
* | ||
* <p>Ensure that the JSON object is escaped correctly <b>Example:</b> <code> | ||
* "{\"action\":{\"name\":\"connectPstn\",\"number\":\"46000000001\",\"maxDuration\":90}}"</code> | ||
* | ||
* @return The Answered Call Event value | ||
*/ | ||
public Optional<String> getAce() { | ||
return Optional.ofNullable(ace); | ||
} | ||
|
||
/** | ||
* <b>Note:</b> PIE callbacks are not available for DATA Calls; only PSTN and SIP calls. | ||
* | ||
* <p>You can use inline <a | ||
* href="https://developers.sinch.com/docs/voice/api-reference/svaml/">SVAML</a> to replace a | ||
* callback URL when using custom callouts. | ||
* | ||
* <p>Ensure that the JSON object is escaped correctly. A PIE event will contain a value chosen | ||
* from an IVR choice. Usually a PIE event wil contain a URL to a callback sever that will receive | ||
* the choice and be able to parse it. This could result in further SVAML or some other | ||
* application logic function. | ||
* | ||
* @return Prompt Input Event value | ||
*/ | ||
public Optional<String> getPie() { | ||
return Optional.ofNullable(pie); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "CalloutRequestParametersCustom{" | ||
+ "maxDuration=" | ||
+ maxDuration | ||
+ ", ice='" | ||
+ ice | ||
+ '\'' | ||
+ ", ace='" | ||
+ ace | ||
+ '\'' | ||
+ ", pie='" | ||
+ pie | ||
+ '\'' | ||
+ "} " | ||
+ super.toString(); | ||
} | ||
|
||
public static Builder builder() { | ||
return new Builder(); | ||
} | ||
|
||
public static class Builder extends CalloutRequestParameters.Builder<Builder> { | ||
|
||
Integer maxDuration; | ||
String ice; | ||
String ace; | ||
String pie; | ||
|
||
public Builder() { | ||
super(); | ||
} | ||
|
||
public Builder setMaxDuration(Integer maxDuration) { | ||
this.maxDuration = maxDuration; | ||
return self(); | ||
} | ||
|
||
public Builder setIce(String ice) { | ||
this.ice = ice; | ||
return self(); | ||
} | ||
|
||
public Builder setAce(String ace) { | ||
this.ace = ace; | ||
return self(); | ||
} | ||
|
||
public Builder setPie(String pie) { | ||
this.pie = pie; | ||
return self(); | ||
} | ||
|
||
public CalloutRequestParametersCustom build() { | ||
return new CalloutRequestParametersCustom( | ||
destination, cli, dtfm, custom, maxDuration, ice, ace, pie); | ||
} | ||
|
||
@Override | ||
protected Builder self() { | ||
return this; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
client/src/main/com/sinch/sdk/domains/voice/models/requests/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** | ||
* Voice API requests related models | ||
* | ||
* @since 1.0 | ||
*/ | ||
package com.sinch.sdk.domains.voice.models.requests; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.