sendTemplate method

Future<SentMessagesResponse> sendTemplate(
  1. String templateName,
  2. OutgoingMessage message, {
  3. Map<String, String>? templateContent,
  4. bool sendAsync = false,
  5. String? ipPool,
  6. DateTime? sendAt,
})
  • templateName: the immutable name or slug of a template that exists in the user's account. For backwards-compatibility, the template name may also be used but the immutable slug is preferred.

  • templateContent: a Map where the key is the content block to set the content for, and the value is the actual content to put into the block.

For sendAsync, ipPool and sendAt please look at the send documentation.

Implementation

Future<SentMessagesResponse> sendTemplate(
  String templateName,
  OutgoingMessage message, {
  Map<String, String>? templateContent,
  bool sendAsync = false,
  String? ipPool,
  DateTime? sendAt,
}) async {
  final body = {
    'template_name': templateName,
    'template_content': utils.toVarList(templateContent),
    'message': KeyedArchive.archive(message),
    'async': sendAsync,
    'ip_pool': ipPool,
    'send_at': MandrillClient.formatDate(sendAt),
  };

  return await client.call(
      'messages/send-template', body, SentMessagesResponse());
}