updateUserNotificationStatus method

Future<void> updateUserNotificationStatus({
  1. required String instanceId,
  2. required String notificationId,
  3. required NotificationStatus status,
  4. required String userId,
  5. String? lastModifiedRegion,
  6. DateTime? lastModifiedTime,
})

Updates the status of a notification for a specific user, such as marking it as read or hidden. Users can only update notification status for notifications that have been sent to them. READ status deprioritizes the notification and greys it out, while HIDDEN status removes it from the notification widget.

May throw AccessDeniedException. May throw InternalServiceException. May throw InvalidParameterException. May throw InvalidRequestException. May throw ResourceNotFoundException. May throw ThrottlingException.

Parameter instanceId : The identifier of the Amazon Connect instance. You can find the instance ID in the Amazon Resource Name (ARN) of the instance.

Parameter notificationId : The unique identifier for the notification.

Parameter status : The new status for the notification. Valid values are READ, UNREAD, and HIDDEN.

Parameter userId : The identifier of the user whose notification status is being updated.

Parameter lastModifiedRegion : The AWS Region where the notification status was last modified. Used for cross-region replication.

Parameter lastModifiedTime : The timestamp when the notification status was last modified. Used for cross-region replication and optimistic locking.

Implementation

Future<void> updateUserNotificationStatus({
  required String instanceId,
  required String notificationId,
  required NotificationStatus status,
  required String userId,
  String? lastModifiedRegion,
  DateTime? lastModifiedTime,
}) async {
  final headers = <String, String>{
    if (lastModifiedRegion != null)
      'x-amz-last-modified-region': lastModifiedRegion.toString(),
    if (lastModifiedTime != null)
      'x-amz-last-modified-time': _s.rfc822ToJson(lastModifiedTime),
  };
  final $payload = <String, dynamic>{
    'Status': status.value,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri:
        '/users/${Uri.encodeComponent(instanceId)}/${Uri.encodeComponent(userId)}/notifications/${Uri.encodeComponent(notificationId)}',
    headers: headers,
    exceptionFnMap: _exceptionFns,
  );
}