-
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.
refactor: Sync numbers and voice callouts with 'Snippet' templating u…
…sage
- Loading branch information
Showing
5 changed files
with
62 additions
and
61 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,33 @@ | ||
package numbers; | ||
|
||
import com.sinch.sdk.domains.numbers.*; | ||
import com.sinch.sdk.domains.numbers.models.*; | ||
import com.sinch.sdk.domains.numbers.models.requests.*; | ||
import com.sinch.sdk.domains.numbers.models.responses.AvailableNumberListResponse; | ||
import java.util.logging.Logger; | ||
|
||
public class Snippet { | ||
|
||
private static final Logger LOGGER = Logger.getLogger(Snippet.class.getName()); | ||
|
||
static void execute(NumbersService numbersService) { | ||
|
||
AvailableNumberService availableNumbersService = numbersService.available(); | ||
|
||
String regionCode = "US"; | ||
NumberType type = NumberType.LOCAL; | ||
|
||
AvailableNumberListAllRequestParameters parameters = | ||
AvailableNumberListAllRequestParameters.builder() | ||
.setRegionCode(regionCode) | ||
.setType(type) | ||
.build(); | ||
|
||
AvailableNumberListResponse response = availableNumbersService.list(parameters); | ||
|
||
response.iterator() | ||
.forEachRemaining( | ||
number -> | ||
LOGGER.info(String.format("Available number details: %s", number))); | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
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,26 @@ | ||
package voice; | ||
|
||
import com.sinch.sdk.domains.voice.*; | ||
import com.sinch.sdk.domains.voice.models.*; | ||
import com.sinch.sdk.domains.voice.models.requests.*; | ||
|
||
public class Snippet { | ||
|
||
public static String execute(VoiceService voiceService) { | ||
|
||
CalloutsService calloutsService = voiceService.callouts(); | ||
|
||
String phoneNumber = "YOUR_phone_number"; | ||
String message = | ||
"Hello, this is a call from Sinch. Congratulations! You made your first call."; | ||
|
||
CalloutRequestParametersTTS parameters = | ||
CalloutRequestParametersTTS.builder() | ||
.setDestination(DestinationNumber.valueOf(phoneNumber)) | ||
.setText(message) | ||
.build(); | ||
|
||
String callId = calloutsService.textToSpeech(parameters); | ||
return callId; | ||
} | ||
} |