sendNotifyTextMessage method

Future<SendNotifyTextMessageResult> sendNotifyTextMessage({
  1. required String destinationPhoneNumber,
  2. required String notifyConfigurationId,
  3. required Map<String, String> templateVariables,
  4. String? configurationSetName,
  5. Map<String, String>? context,
  6. bool? dryRun,
  7. bool? messageFeedbackEnabled,
  8. String? templateId,
  9. int? timeToLive,
})

Sends a templated text message through a notify configuration to a recipient's phone number.

May throw AccessDeniedException. May throw ConflictException. May throw InternalServerException. May throw ResourceNotFoundException. May throw ServiceQuotaExceededException. May throw ThrottlingException. May throw ValidationException.

Parameter destinationPhoneNumber : The destination phone number in E.164 format.

Parameter notifyConfigurationId : The unique identifier of the notify configuration to use for sending the message. This can be either the NotifyConfigurationId or NotifyConfigurationArn.

Parameter templateVariables : A map of template variable names and their values. All variable values are passed as strings regardless of the declared variable type. For example, pass INTEGER values as "42" and BOOLEAN values as "true" or "false".

Parameter configurationSetName : The name of the configuration set to use. This can be either the ConfigurationSetName or ConfigurationSetArn.

Parameter context : You can specify custom data in this field. If you do, that data is logged to the event destination.

Parameter dryRun : When set to true, the message is checked and validated, but isn't sent to the end recipient.

Parameter messageFeedbackEnabled : Set to true to enable message feedback for the message. When a user receives the message you need to update the message status using PutMessageFeedback.

Parameter templateId : The unique identifier of the template to use for the message.

Parameter timeToLive : How long the text message is valid for, in seconds. By default this is 72 hours.

Implementation

Future<SendNotifyTextMessageResult> sendNotifyTextMessage({
  required String destinationPhoneNumber,
  required String notifyConfigurationId,
  required Map<String, String> templateVariables,
  String? configurationSetName,
  Map<String, String>? context,
  bool? dryRun,
  bool? messageFeedbackEnabled,
  String? templateId,
  int? timeToLive,
}) async {
  _s.validateNumRange(
    'timeToLive',
    timeToLive,
    5,
    259200,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.0',
    'X-Amz-Target': 'PinpointSMSVoiceV2.SendNotifyTextMessage'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'DestinationPhoneNumber': destinationPhoneNumber,
      'NotifyConfigurationId': notifyConfigurationId,
      'TemplateVariables': templateVariables,
      if (configurationSetName != null)
        'ConfigurationSetName': configurationSetName,
      if (context != null) 'Context': context,
      if (dryRun != null) 'DryRun': dryRun,
      if (messageFeedbackEnabled != null)
        'MessageFeedbackEnabled': messageFeedbackEnabled,
      if (templateId != null) 'TemplateId': templateId,
      if (timeToLive != null) 'TimeToLive': timeToLive,
    },
  );

  return SendNotifyTextMessageResult.fromJson(jsonResponse.body);
}