Skip to content

Commit

Permalink
refactor (Numbers): Use Numbers v1()
Browse files Browse the repository at this point in the history
  • Loading branch information
JPPortier committed Jul 4, 2024
1 parent 738b699 commit 3ef0b5e
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 33 deletions.
18 changes: 9 additions & 9 deletions snippets/numbers/active_update/Snippet.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
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.ActiveNumberService;
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.active.request.ActiveNumberUpdateRequest;
import java.util.logging.Logger;

public class Snippet {
Expand All @@ -19,11 +20,10 @@ static void execute(NumbersService numbersService) {
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();
Expand Down
13 changes: 7 additions & 6 deletions snippets/numbers/available_list/Snippet.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
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.AvailableNumberService;
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.available.request.AvailableNumberListRequest;
import com.sinch.sdk.domains.numbers.models.v1.available.response.AvailableNumberListResponse;
import java.util.logging.Logger;

public class Snippet {
Expand All @@ -17,8 +18,8 @@ static void execute(NumbersService numbersService) {
String regionCode = "US";
NumberType type = NumberType.LOCAL;

AvailableNumberListAllRequestParameters parameters =
AvailableNumberListAllRequestParameters.builder()
AvailableNumberListRequest parameters =
AvailableNumberListRequest.builder()
.setRegionCode(regionCode)
.setType(type)
.build();
Expand Down
18 changes: 9 additions & 9 deletions snippets/numbers/rent/Snippet.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
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.AvailableNumberService;
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.available.request.AvailableNumberRentRequest;
import java.util.logging.Logger;

public class Snippet {
Expand All @@ -20,11 +20,11 @@ static void execute(NumbersService numbersService) {
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()
AvailableNumberRentRequest rentRequest =
AvailableNumberRentRequest.builder()
.setSmsConfiguration(smsConfiguration)
.build();

Expand Down
18 changes: 9 additions & 9 deletions snippets/numbers/rent_any/Snippet.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
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.AvailableNumberService;
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.available.request.AvailableNumberRentAnyRequest;
import java.util.Collections;
import java.util.logging.Logger;

Expand All @@ -26,12 +26,12 @@ static void execute(NumbersService numbersService) {

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

0 comments on commit 3ef0b5e

Please sign in to comment.