Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEVEXP-468: use Versioned numbers v1 #8

Merged
merged 5 commits into from
Jul 16, 2024
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: 2 additions & 2 deletions compile.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh

(cd snippets && mvn clean spotless:apply)
(cd snippets && ./compile.sh)
(cd snippets && mvn clean spotless:apply) || exit 1
(cd snippets && ./compile.sh) ||exit 1

6 changes: 1 addition & 5 deletions snippets/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,5 @@ echo "Compiling snippets:"
for snippet in $SNIPPETS
do
echo " - Snippet: $snippet"
mvn compile -Dsnippet="$(dirname $snippet)"
if [ $? -ne 0 ]
then
exit $?
fi
mvn compile -Dsnippet="$(dirname $snippet)" || exit 1
done
21 changes: 9 additions & 12 deletions snippets/numbers/active_update/Snippet.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package numbers;

import com.sinch.sdk.domains.numbers.ActiveNumberService;
import com.sinch.sdk.domains.numbers.NumbersService;
import com.sinch.sdk.domains.numbers.models.ActiveNumber;
import com.sinch.sdk.domains.numbers.models.requests.ActiveNumberUpdateRequestParameters;
import com.sinch.sdk.domains.numbers.models.requests.ActiveNumberUpdateVoiceConfigurationRequestParameters;
import com.sinch.sdk.domains.numbers.api.v1.NumbersService;
import com.sinch.sdk.domains.numbers.models.v1.ActiveNumber;
import com.sinch.sdk.domains.numbers.models.v1.VoiceConfiguration;
import com.sinch.sdk.domains.numbers.models.v1.VoiceConfigurationRTC;
import com.sinch.sdk.domains.numbers.models.v1.request.ActiveNumberUpdateRequest;
import java.util.logging.Logger;

public class Snippet {
Expand All @@ -13,22 +13,19 @@ public class Snippet {

static void execute(NumbersService numbersService) {

ActiveNumberService activeNumbersService = numbersService.active();

String phoneNumber = "YOUR_phone_number_to_be_updated";
String appId = "YOUR_app_id";
String displayName = "Updated from Sinch Java SDK";

ActiveNumberUpdateVoiceConfigurationRequestParameters voiceConfiguration =
ActiveNumberUpdateVoiceConfigurationRequestParameters.builder().setAppId(appId).build();
VoiceConfiguration voiceConfiguration = VoiceConfigurationRTC.builder().setAppId(appId).build();

ActiveNumberUpdateRequestParameters updateRequest =
ActiveNumberUpdateRequestParameters.builder()
ActiveNumberUpdateRequest updateRequest =
ActiveNumberUpdateRequest.builder()
.setDisplayName(displayName)
.setVoiceConfiguration(voiceConfiguration)
.build();

ActiveNumber response = activeNumbersService.update(phoneNumber, updateRequest);
ActiveNumber response = numbersService.update(phoneNumber, updateRequest);

LOGGER.info(String.format("Updated number: %s", response));
}
Expand Down
19 changes: 7 additions & 12 deletions snippets/numbers/available_list/Snippet.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
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 com.sinch.sdk.domains.numbers.api.v1.NumbersService;
import com.sinch.sdk.domains.numbers.models.v1.NumberType;
import com.sinch.sdk.domains.numbers.models.v1.request.AvailableNumberListRequest;
import com.sinch.sdk.domains.numbers.models.v1.response.AvailableNumberListResponse;
import java.util.logging.Logger;

public class Snippet {
Expand All @@ -12,18 +12,13 @@ public class Snippet {

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();
AvailableNumberListRequest parameters =
AvailableNumberListRequest.builder().setRegionCode(regionCode).setType(type).build();

AvailableNumberListResponse response = availableNumbersService.list(parameters);
AvailableNumberListResponse response = numbersService.searchForAvailableNumbers(parameters);

response
.iterator()
Expand Down
23 changes: 9 additions & 14 deletions snippets/numbers/rent/Snippet.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package numbers;

import com.sinch.sdk.domains.numbers.AvailableNumberService;
import com.sinch.sdk.domains.numbers.NumbersService;
import com.sinch.sdk.domains.numbers.models.ActiveNumber;
import com.sinch.sdk.domains.numbers.models.requests.AvailableNumberRentRequestParameters;
import com.sinch.sdk.domains.numbers.models.requests.RentSMSConfigurationRequestParameters;
import com.sinch.sdk.domains.numbers.api.v1.NumbersService;
import com.sinch.sdk.domains.numbers.models.v1.ActiveNumber;
import com.sinch.sdk.domains.numbers.models.v1.SmsConfiguration;
import com.sinch.sdk.domains.numbers.models.v1.request.AvailableNumberRentRequest;
import java.util.logging.Logger;

public class Snippet {
Expand All @@ -13,22 +12,18 @@ public class Snippet {

static void execute(NumbersService numbersService) {

AvailableNumberService availableNumbersService = numbersService.available();

// Available numbers list can be retrieved by using list() function from available service, see:
// https://developers.sinch.com/quickstart-getting-started-poc/docs/numbers/getting-started/java-sdk/searchavailable
String phoneNumber = "available_phone_number_to_be_rented";
String servicePlanId = "YOUR_service_plan_id";

RentSMSConfigurationRequestParameters smsConfiguration =
RentSMSConfigurationRequestParameters.builder().setServicePlanId(servicePlanId).build();
SmsConfiguration smsConfiguration =
SmsConfiguration.builder().setServicePlanId(servicePlanId).build();

AvailableNumberRentRequestParameters rentRequest =
AvailableNumberRentRequestParameters.builder()
.setSmsConfiguration(smsConfiguration)
.build();
AvailableNumberRentRequest rentRequest =
AvailableNumberRentRequest.builder().setSmsConfiguration(smsConfiguration).build();

ActiveNumber response = availableNumbersService.rent(phoneNumber, rentRequest);
ActiveNumber response = numbersService.rent(phoneNumber, rentRequest);

LOGGER.info(String.format("Rented number: %s", response));
}
Expand Down
23 changes: 9 additions & 14 deletions snippets/numbers/rent_any/Snippet.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package numbers;

import com.sinch.sdk.domains.numbers.AvailableNumberService;
import com.sinch.sdk.domains.numbers.NumbersService;
import com.sinch.sdk.domains.numbers.models.ActiveNumber;
import com.sinch.sdk.domains.numbers.models.Capability;
import com.sinch.sdk.domains.numbers.models.NumberType;
import com.sinch.sdk.domains.numbers.models.requests.AvailableNumberRentAnyRequestParameters;
import com.sinch.sdk.domains.numbers.models.requests.RentSMSConfigurationRequestParameters;
import com.sinch.sdk.domains.numbers.api.v1.NumbersService;
import com.sinch.sdk.domains.numbers.models.v1.ActiveNumber;
import com.sinch.sdk.domains.numbers.models.v1.Capability;
import com.sinch.sdk.domains.numbers.models.v1.NumberType;
import com.sinch.sdk.domains.numbers.models.v1.SmsConfiguration;
import com.sinch.sdk.domains.numbers.models.v1.request.AvailableNumberRentAnyRequest;
import java.util.Collections;
import java.util.logging.Logger;

Expand All @@ -16,24 +15,20 @@ public class Snippet {

static void execute(NumbersService numbersService) {

AvailableNumberService availableNumbersService = numbersService.available();

String servicePlanId = "YOUR_service_plan_id";
String regionCode = "YOUR_region_code";

Capability capability = Capability.SMS;
NumberType numberType = NumberType.LOCAL;

ActiveNumber response =
availableNumbersService.rentAny(
AvailableNumberRentAnyRequestParameters.builder()
numbersService.rentAny(
AvailableNumberRentAnyRequest.builder()
.setCapabilities(Collections.singletonList(capability))
.setType(numberType)
.setRegionCode(regionCode)
.setSmsConfiguration(
RentSMSConfigurationRequestParameters.builder()
.setServicePlanId(servicePlanId)
.build())
SmsConfiguration.builder().setServicePlanId(servicePlanId).build())
.build());

LOGGER.info(String.format("Rented number: %s", response));
Expand Down
Loading