diff --git a/snippets/numbers/available/List.java b/snippets/numbers/available/List.java deleted file mode 100644 index fdbb6ab..0000000 --- a/snippets/numbers/available/List.java +++ /dev/null @@ -1,32 +0,0 @@ -package numbers; - -import com.sinch.sdk.domains.numbers.*; -import com.sinch.sdk.domains.numbers.models.NumberType; -import com.sinch.sdk.domains.numbers.models.requests.AvailableNumberListAllRequestParameters; -import java.util.logging.Logger; - -public class List { - - private static final Logger LOGGER = Logger.getLogger(List.class.getName()); - - public void list(NumbersService numbersService) { - - var availableNumbersService = numbersService.available(); - - var regionCode = "US"; - var type = NumberType.LOCAL; - - var parameters = - AvailableNumberListAllRequestParameters.builder() - .setRegionCode(regionCode) - .setType(type) - .build(); - - var response = availableNumbersService.list(parameters); - - response.iterator() - .forEachRemaining( - number -> - LOGGER.info(String.format("Available number details: %s", number))); - } -} diff --git a/snippets/numbers/available_list/Snippet.java b/snippets/numbers/available_list/Snippet.java new file mode 100644 index 0000000..47657ef --- /dev/null +++ b/snippets/numbers/available_list/Snippet.java @@ -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))); + } +} diff --git a/snippets/pom.xml b/snippets/pom.xml index 0605658..37dfcde 100644 --- a/snippets/pom.xml +++ b/snippets/pom.xml @@ -12,9 +12,9 @@ [1.0.0,) - 21 - 21 - 3.8.0 + 8 + 8 + 3.13.0 UTF-8 diff --git a/snippets/sms/send/Snippet.java b/snippets/sms/send/Snippet.java new file mode 100644 index 0000000..4e465fd --- /dev/null +++ b/snippets/sms/send/Snippet.java @@ -0,0 +1,33 @@ +package sms; + +import com.sinch.sdk.domains.sms.*; +import com.sinch.sdk.domains.sms.models.*; +import com.sinch.sdk.domains.sms.models.requests.*; +import java.util.Collection; +import java.util.Collections; +import java.util.logging.Logger; + +public class Snippet { + + private static final Logger LOGGER = Logger.getLogger(Snippet.class.getName()); + + static void execute(SMSService smsService) { + + BatchesService batchesService = smsService.batches(); + + String from = "YOUR_sinch_phone_number"; + Collection recipients = Collections.singletonList("YOUR_recipient_phone_number"); + String body = "This is a test SMS message using the Sinch Java SDK."; + + LOGGER.info("Sending SMS Text"); + BatchText value = + batchesService.send( + SendSmsBatchTextRequest.builder() + .setTo(recipients) + .setBody(body) + .setFrom(from) + .build()); + + LOGGER.info("Response: " + value); + } +} diff --git a/snippets/voice/callouts/TextToSpeech.java b/snippets/voice/callouts/TextToSpeech.java deleted file mode 100644 index a11e2a1..0000000 --- a/snippets/voice/callouts/TextToSpeech.java +++ /dev/null @@ -1,26 +0,0 @@ -package voice.callouts; - -import com.sinch.sdk.domains.voice.*; -import com.sinch.sdk.domains.voice.models.DestinationNumber; -import com.sinch.sdk.domains.voice.models.requests.CalloutRequestParametersTTS; - -public class TextToSpeech { - - public String call(VoiceService voiceService, String phoneNumber) { - - var calloutsService = voiceService.callouts(); - - var destination = DestinationNumber.valueOf(phoneNumber); - var message = - "Hello, this is a call from Sinch. Congratulations! You made your first call."; - - var parameters = - CalloutRequestParametersTTS.builder() - .setDestination(destination) - .setText(message) - .build(); - - var callId = calloutsService.textToSpeech(parameters); - return callId; - } -} diff --git a/snippets/voice/callouts_text_to_speech/Snippet.java b/snippets/voice/callouts_text_to_speech/Snippet.java new file mode 100644 index 0000000..9c674ca --- /dev/null +++ b/snippets/voice/callouts_text_to_speech/Snippet.java @@ -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; + } +}