From 3a1e40c8a6d8964fe538062d91dbca158334dfba Mon Sep 17 00:00:00 2001 From: Jean-Pierre Portier Date: Wed, 5 Jun 2024 16:07:55 +0200 Subject: [PATCH] Adding Verification snippet --- snippets/verification/start_sms/Snippet.java | 31 ++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 snippets/verification/start_sms/Snippet.java diff --git a/snippets/verification/start_sms/Snippet.java b/snippets/verification/start_sms/Snippet.java new file mode 100644 index 0000000..eb31bd5 --- /dev/null +++ b/snippets/verification/start_sms/Snippet.java @@ -0,0 +1,31 @@ +package verification; + +import com.sinch.sdk.domains.verification.*; +import com.sinch.sdk.domains.verification.models.*; +import com.sinch.sdk.domains.verification.models.requests.*; +import com.sinch.sdk.domains.verification.models.response.*; +import java.util.logging.Logger; + +public class Snippet { + + private static final Logger LOGGER = Logger.getLogger(Snippet.class.getName()); + + static void execute(VerificationService verificationService) { + + // REMINDER: verification Service require to have set application key/secret + // onto Sinch Client init + VerificationsService verificationsService = verificationService.verifications(); + + String phoneNumber = "YOUR_phone_number"; + + LOGGER.info(String.format("Sending a SMS verification to '%s'", phoneNumber)); + + StartVerificationResponseSMS response = + verificationsService.startSms( + StartVerificationSMSRequestParameters.builder() + .setIdentity(NumberIdentity.valueOf(phoneNumber)) + .build()); + + LOGGER.info("Response: " + response); + } +}