Skip to content

Commit

Permalink
feature: Send SMS snippet
Browse files Browse the repository at this point in the history
  • Loading branch information
JPPortier committed May 31, 2024
1 parent 2781c4f commit 582480e
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions snippets/sms/send/Snippet.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package sms;

import com.sinch.sdk.domains.sms.*;
import com.sinch.sdk.domains.sms.models.*;
import com.sinch.sdk.domains.sms.models.requests.*;
import java.util.Collection;
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(SMSService smsService) {

BatchesService batchesService = smsService.batches();

String from = "YOUR_sinch_phone_number";
Collection<String> recipients = Collections.singletonList("YOUR_recipient_phone_number");
String body = "This is a test SMS message using the Sinch Java SDK.";

LOGGER.info("Sending SMS Text");
BatchText value =
batchesService.send(
SendSmsBatchTextRequest.builder()
.setTo(recipients)
.setBody(body)
.setFrom(from)
.build());

LOGGER.info("Response: " + value);
}
}

0 comments on commit 582480e

Please sign in to comment.