sendSms method

Future<SendSmsResponse> sendSms(
  1. SendSmsRequest request
)

Sends a single SMS via POST /send.

Implementation

Future<SendSmsResponse> sendSms(SendSmsRequest request) async {
  if (request.to.isEmpty || request.message.isEmpty) {
    throw AfroMessageException('Both to and message are required.');
  }

  final body = request.toJson(
    defaultFrom: config.identifierId,
    defaultSender: config.senderName,
  );

  final json = await _postJson('/send', body);
  return SendSmsResponse.fromJson(json);
}