requestSenderId method

Future<RequestSenderIdResult> requestSenderId({
  1. required String isoCountryCode,
  2. required String senderId,
  3. String? clientToken,
  4. bool? deletionProtectionEnabled,
  5. List<MessageType>? messageTypes,
  6. List<Tag>? tags,
})

Request a new sender ID that doesn't require registration.

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

Parameter isoCountryCode : The two-character code, in ISO 3166-1 alpha-2 format, for the country or region.

Parameter senderId : The sender ID string to request.

Parameter clientToken : Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. If you don't specify a client token, a randomly generated token is used for the request to ensure idempotency.

Parameter deletionProtectionEnabled : By default this is set to false. When set to true the sender ID can't be deleted.

Parameter messageTypes : The type of message. Valid values are TRANSACTIONAL for messages that are critical or time-sensitive and PROMOTIONAL for messages that aren't critical or time-sensitive.

Parameter tags : An array of tags (key and value pairs) to associate with the sender ID.

Implementation

Future<RequestSenderIdResult> requestSenderId({
  required String isoCountryCode,
  required String senderId,
  String? clientToken,
  bool? deletionProtectionEnabled,
  List<MessageType>? messageTypes,
  List<Tag>? tags,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.0',
    'X-Amz-Target': 'PinpointSMSVoiceV2.RequestSenderId'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'IsoCountryCode': isoCountryCode,
      'SenderId': senderId,
      'ClientToken': clientToken ?? _s.generateIdempotencyToken(),
      if (deletionProtectionEnabled != null)
        'DeletionProtectionEnabled': deletionProtectionEnabled,
      if (messageTypes != null)
        'MessageTypes': messageTypes.map((e) => e.value).toList(),
      if (tags != null) 'Tags': tags,
    },
  );

  return RequestSenderIdResult.fromJson(jsonResponse.body);
}