Search in sources :

Example 1 with CheckIfPhoneNumberIsOptedOutResponse

use of software.amazon.awssdk.services.sns.model.CheckIfPhoneNumberIsOptedOutResponse in project aws-doc-sdk-examples by awsdocs.

the class CheckOptOut method checkPhone.

// snippet-start:[sns.java2.CheckOptOut.main]
public static void checkPhone(SnsClient snsClient, String phoneNumber) {
    try {
        CheckIfPhoneNumberIsOptedOutRequest request = CheckIfPhoneNumberIsOptedOutRequest.builder().phoneNumber(phoneNumber).build();
        CheckIfPhoneNumberIsOptedOutResponse result = snsClient.checkIfPhoneNumberIsOptedOut(request);
        System.out.println(result.isOptedOut() + "Phone Number " + phoneNumber + " has Opted Out of receiving sns messages." + "\n\nStatus was " + result.sdkHttpResponse().statusCode());
    } catch (SnsException e) {
        System.err.println(e.awsErrorDetails().errorMessage());
        System.exit(1);
    }
}
Also used : CheckIfPhoneNumberIsOptedOutRequest(software.amazon.awssdk.services.sns.model.CheckIfPhoneNumberIsOptedOutRequest) SnsException(software.amazon.awssdk.services.sns.model.SnsException) CheckIfPhoneNumberIsOptedOutResponse(software.amazon.awssdk.services.sns.model.CheckIfPhoneNumberIsOptedOutResponse)

Aggregations

CheckIfPhoneNumberIsOptedOutRequest (software.amazon.awssdk.services.sns.model.CheckIfPhoneNumberIsOptedOutRequest)1 CheckIfPhoneNumberIsOptedOutResponse (software.amazon.awssdk.services.sns.model.CheckIfPhoneNumberIsOptedOutResponse)1 SnsException (software.amazon.awssdk.services.sns.model.SnsException)1