updatePhoneNumber method

Future<UpdatePhoneNumberResult> updatePhoneNumber({
  1. required String phoneNumberId,
  2. bool? deletionProtectionEnabled,
  3. bool? internationalSendingEnabled,
  4. String? optOutListName,
  5. bool? selfManagedOptOutsEnabled,
  6. String? twoWayChannelArn,
  7. String? twoWayChannelRole,
  8. bool? twoWayEnabled,
})

Updates the configuration of an existing origination phone number. You can update the opt-out list, enable or disable two-way messaging, change the TwoWayChannelArn, enable or disable self-managed opt-outs, and enable or disable deletion protection.

If the origination phone number is associated with a pool, an error is returned.

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

Parameter phoneNumberId : The unique identifier of the phone number. Valid values for this field can be either the PhoneNumberId or PhoneNumberArn.

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

Parameter internationalSendingEnabled : By default this is set to false. When set to true the international sending of phone number is Enabled.

Parameter optOutListName : The OptOutList to add the phone number to. You can use either the opt out list name or the opt out list ARN.

Parameter selfManagedOptOutsEnabled : By default this is set to false. When set to false and an end recipient sends a message that begins with HELP or STOP to one of your dedicated numbers, End User Messaging SMS automatically replies with a customizable message and adds the end recipient to the OptOutList. When set to true you're responsible for responding to HELP and STOP requests. You're also responsible for tracking and honoring opt-out requests.

Parameter twoWayChannelArn : The Amazon Resource Name (ARN) of the two way channel.

Parameter twoWayChannelRole : An optional IAM Role Arn for a service to assume, to be able to post inbound SMS messages.

Parameter twoWayEnabled : By default this is set to false. When set to true you can receive incoming text messages from your end recipients.

Implementation

Future<UpdatePhoneNumberResult> updatePhoneNumber({
  required String phoneNumberId,
  bool? deletionProtectionEnabled,
  bool? internationalSendingEnabled,
  String? optOutListName,
  bool? selfManagedOptOutsEnabled,
  String? twoWayChannelArn,
  String? twoWayChannelRole,
  bool? twoWayEnabled,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.0',
    'X-Amz-Target': 'PinpointSMSVoiceV2.UpdatePhoneNumber'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'PhoneNumberId': phoneNumberId,
      if (deletionProtectionEnabled != null)
        'DeletionProtectionEnabled': deletionProtectionEnabled,
      if (internationalSendingEnabled != null)
        'InternationalSendingEnabled': internationalSendingEnabled,
      if (optOutListName != null) 'OptOutListName': optOutListName,
      if (selfManagedOptOutsEnabled != null)
        'SelfManagedOptOutsEnabled': selfManagedOptOutsEnabled,
      if (twoWayChannelArn != null) 'TwoWayChannelArn': twoWayChannelArn,
      if (twoWayChannelRole != null) 'TwoWayChannelRole': twoWayChannelRole,
      if (twoWayEnabled != null) 'TwoWayEnabled': twoWayEnabled,
    },
  );

  return UpdatePhoneNumberResult.fromJson(jsonResponse.body);
}