createComment method

Future<CreateCommentResponse> createComment({
  1. required String documentId,
  2. required String text,
  3. required String versionId,
  4. String? authenticationToken,
  5. bool? notifyCollaborators,
  6. String? parentId,
  7. String? threadId,
  8. CommentVisibilityType? visibility,
})

Adds a new comment to the specified document version.

May throw EntityNotExistsException. May throw ProhibitedStateException. May throw UnauthorizedOperationException. May throw UnauthorizedResourceAccessException. May throw FailedDependencyException. May throw ServiceUnavailableException. May throw DocumentLockedForCommentsException. May throw InvalidCommentOperationException.

Parameter documentId : The ID of the document.

Parameter text : The text of the comment.

Parameter versionId : The ID of the document version.

Parameter authenticationToken : Amazon WorkDocs authentication token. Not required when using AWS administrator credentials to access the API.

Parameter notifyCollaborators : Set this parameter to TRUE to send an email out to the document collaborators after the comment is created.

Parameter parentId : The ID of the parent comment.

Parameter threadId : The ID of the root comment in the thread.

Parameter visibility : The visibility of the comment. Options are either PRIVATE, where the comment is visible only to the comment author and document owner and co-owners, or PUBLIC, where the comment is visible to document owners, co-owners, and contributors.

Implementation

Future<CreateCommentResponse> createComment({
  required String documentId,
  required String text,
  required String versionId,
  String? authenticationToken,
  bool? notifyCollaborators,
  String? parentId,
  String? threadId,
  CommentVisibilityType? visibility,
}) async {
  ArgumentError.checkNotNull(documentId, 'documentId');
  _s.validateStringLength(
    'documentId',
    documentId,
    1,
    128,
    isRequired: true,
  );
  ArgumentError.checkNotNull(text, 'text');
  _s.validateStringLength(
    'text',
    text,
    1,
    2048,
    isRequired: true,
  );
  ArgumentError.checkNotNull(versionId, 'versionId');
  _s.validateStringLength(
    'versionId',
    versionId,
    1,
    128,
    isRequired: true,
  );
  _s.validateStringLength(
    'authenticationToken',
    authenticationToken,
    1,
    8199,
  );
  _s.validateStringLength(
    'parentId',
    parentId,
    1,
    128,
  );
  _s.validateStringLength(
    'threadId',
    threadId,
    1,
    128,
  );
  final headers = <String, String>{
    if (authenticationToken != null)
      'Authentication': authenticationToken.toString(),
  };
  final $payload = <String, dynamic>{
    'Text': text,
    if (notifyCollaborators != null)
      'NotifyCollaborators': notifyCollaborators,
    if (parentId != null) 'ParentId': parentId,
    if (threadId != null) 'ThreadId': threadId,
    if (visibility != null) 'Visibility': visibility.toValue(),
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri:
        '/api/v1/documents/${Uri.encodeComponent(documentId)}/versions/${Uri.encodeComponent(versionId)}/comment',
    headers: headers,
    exceptionFnMap: _exceptionFns,
  );
  return CreateCommentResponse.fromJson(response);
}