Skip to content

Commit

Permalink
feature: RentAndConfigure snippet
Browse files Browse the repository at this point in the history
  • Loading branch information
JPPortier committed Jun 18, 2024
1 parent 9bd054d commit 2a12786
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions snippets/numbers/rent_and_config/Snippet.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
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 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 servicePlanId = "YOUR_service_plan_id";
String phoneNumber = "YOUR_phone_number";

ActiveNumber response =
availableNumbersService.rent(
phoneNumber,
AvailableNumberRentRequestParameters.builder()
.setSmsConfiguration(
RentSMSConfigurationRequestParameters.builder()
.setServicePlanId(servicePlanId)
.build())
.build());

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

0 comments on commit 2a12786

Please sign in to comment.