sendMediaMessage method

Future<SendMediaMessageResult> sendMediaMessage({
  1. required String destinationPhoneNumber,
  2. required String originationIdentity,
  3. String? configurationSetName,
  4. Map<String, String>? context,
  5. bool? dryRun,
  6. String? maxPrice,
  7. List<String>? mediaUrls,
  8. String? messageBody,
  9. bool? messageFeedbackEnabled,
  10. String? protectConfigurationId,
  11. int? timeToLive,
})

Creates a new multimedia message (MMS) and sends it 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 originationIdentity : The origination identity of the message. This can be either the PhoneNumber, PhoneNumberId, PhoneNumberArn, SenderId, SenderIdArn, PoolId, or PoolArn.

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 maxPrice : The maximum amount that you want to spend, in US dollars, per each MMS message.

Parameter mediaUrls : An array of URLs to each media file to send.

The media files have to be stored in an S3 bucket. Supported media file formats are listed in MMS file types, size and character limits. For more information on creating an S3 bucket and managing objects, see Creating a bucket, Uploading objects in the Amazon S3 User Guide, and Setting up an Amazon S3 bucket for MMS files in the Amazon Web Services End User Messaging SMS User Guide.

Parameter messageBody : The text body of the message.

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 protectConfigurationId : The unique identifier of the protect configuration to use.

Parameter timeToLive : How long the media message is valid for. By default this is 72 hours.

Implementation

Future<SendMediaMessageResult> sendMediaMessage({
  required String destinationPhoneNumber,
  required String originationIdentity,
  String? configurationSetName,
  Map<String, String>? context,
  bool? dryRun,
  String? maxPrice,
  List<String>? mediaUrls,
  String? messageBody,
  bool? messageFeedbackEnabled,
  String? protectConfigurationId,
  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.SendMediaMessage'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'DestinationPhoneNumber': destinationPhoneNumber,
      'OriginationIdentity': originationIdentity,
      if (configurationSetName != null)
        'ConfigurationSetName': configurationSetName,
      if (context != null) 'Context': context,
      if (dryRun != null) 'DryRun': dryRun,
      if (maxPrice != null) 'MaxPrice': maxPrice,
      if (mediaUrls != null) 'MediaUrls': mediaUrls,
      if (messageBody != null) 'MessageBody': messageBody,
      if (messageFeedbackEnabled != null)
        'MessageFeedbackEnabled': messageFeedbackEnabled,
      if (protectConfigurationId != null)
        'ProtectConfigurationId': protectConfigurationId,
      if (timeToLive != null) 'TimeToLive': timeToLive,
    },
  );

  return SendMediaMessageResult.fromJson(jsonResponse.body);
}