startEngagement method

Future<StartEngagementResult> startEngagement({
  1. required String contactId,
  2. required String content,
  3. required String sender,
  4. required String subject,
  5. String? idempotencyToken,
  6. String? incidentId,
  7. String? publicContent,
  8. String? publicSubject,
})

Starts an engagement to a contact or escalation plan. The engagement engages each contact specified in the incident.

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

Parameter contactId : The Amazon Resource Name (ARN) of the contact being engaged.

Parameter content : The secure content of the message that was sent to the contact. Use this field for engagements to VOICE or EMAIL.

Parameter sender : The user that started the engagement.

Parameter subject : The secure subject of the message that was sent to the contact. Use this field for engagements to VOICE or EMAIL.

Parameter idempotencyToken : A token ensuring that the operation is called only once with the specified details.

Parameter incidentId : The ARN of the incident that the engagement is part of.

Parameter publicContent : The insecure content of the message that was sent to the contact. Use this field for engagements to SMS.

Parameter publicSubject : The insecure subject of the message that was sent to the contact. Use this field for engagements to SMS.

Implementation

Future<StartEngagementResult> startEngagement({
  required String contactId,
  required String content,
  required String sender,
  required String subject,
  String? idempotencyToken,
  String? incidentId,
  String? publicContent,
  String? publicSubject,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'SSMContacts.StartEngagement'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'ContactId': contactId,
      'Content': content,
      'Sender': sender,
      'Subject': subject,
      'IdempotencyToken': idempotencyToken ?? _s.generateIdempotencyToken(),
      if (incidentId != null) 'IncidentId': incidentId,
      if (publicContent != null) 'PublicContent': publicContent,
      if (publicSubject != null) 'PublicSubject': publicSubject,
    },
  );

  return StartEngagementResult.fromJson(jsonResponse.body);
}