updateContact method

Future<void> updateContact({
  1. required String contactListName,
  2. required String emailAddress,
  3. String? attributesData,
  4. List<TopicPreference>? topicPreferences,
  5. bool? unsubscribeAll,
})

Updates a contact's preferences for a list. It is not necessary to specify all existing topic preferences in the TopicPreferences object, just the ones that need updating.

May throw BadRequestException. May throw TooManyRequestsException. May throw NotFoundException. May throw ConcurrentModificationException.

Parameter contactListName : The name of the contact list.

Parameter emailAddress : The contact's email addres.

Parameter attributesData : The attribute data attached to a contact.

Parameter topicPreferences : The contact's preference for being opted-in to or opted-out of a topic.

Parameter unsubscribeAll : A boolean value status noting if the contact is unsubscribed from all contact list topics.

Implementation

Future<void> updateContact({
  required String contactListName,
  required String emailAddress,
  String? attributesData,
  List<TopicPreference>? topicPreferences,
  bool? unsubscribeAll,
}) async {
  ArgumentError.checkNotNull(contactListName, 'contactListName');
  ArgumentError.checkNotNull(emailAddress, 'emailAddress');
  final $payload = <String, dynamic>{
    if (attributesData != null) 'AttributesData': attributesData,
    if (topicPreferences != null) 'TopicPreferences': topicPreferences,
    if (unsubscribeAll != null) 'UnsubscribeAll': unsubscribeAll,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'PUT',
    requestUri:
        '/v2/email/contact-lists/${Uri.encodeComponent(contactListName)}/contacts/${Uri.encodeComponent(emailAddress)}',
    exceptionFnMap: _exceptionFns,
  );
}