From c1bb1e2d90a92fcaff9dea6dfcf6d10209958b5d Mon Sep 17 00:00:00 2001 From: Jean-Pierre Portier Date: Thu, 20 Jun 2024 15:45:18 +0200 Subject: [PATCH] feature (Numbers/update): Add 'active number update' snippet --- snippets/numbers/active_update/Snippet.java | 35 +++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 snippets/numbers/active_update/Snippet.java diff --git a/snippets/numbers/active_update/Snippet.java b/snippets/numbers/active_update/Snippet.java new file mode 100644 index 0000000..a064544 --- /dev/null +++ b/snippets/numbers/active_update/Snippet.java @@ -0,0 +1,35 @@ +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 java.util.logging.Logger; + +public class Snippet { + + private static final Logger LOGGER = Logger.getLogger(Snippet.class.getName()); + + static void execute(NumbersService numbersService) { + + ActiveNumberService activeNumbersService = numbersService.active(); + + String phoneNumber = "YOUR_phone_number_to_be_rented"; + String appId = "YOUR_app_id"; + String displayName = "Updated from Sinch Java SDK"; + + ActiveNumberUpdateVoiceConfigurationRequestParameters voiceConfiguration = + ActiveNumberUpdateVoiceConfigurationRequestParameters.builder().setAppId(appId).build(); + + ActiveNumberUpdateRequestParameters updateRequest = + ActiveNumberUpdateRequestParameters.builder() + .setDisplayName(displayName) + .setVoiceConfiguration(voiceConfiguration) + .build(); + + ActiveNumber response = activeNumbersService.update(phoneNumber, updateRequest); + + LOGGER.info(String.format("Updated number: %s", response)); + } +}