Skip to content

Commit

Permalink
feature: RentAny snippet
Browse files Browse the repository at this point in the history
  • Loading branch information
JPPortier committed Jun 18, 2024
1 parent 4ec2838 commit 9bd054d
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions snippets/numbers/rent_any/Snippet.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
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 java.util.Collections;
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 regionCode = "YOUR_region_code";

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

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

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

0 comments on commit 9bd054d

Please sign in to comment.