setModerationStatus method

Future<void> setModerationStatus(
  1. List<String> id,
  2. String moderationStatus, {
  3. bool? banAuthor,
  4. String? $fields,
})

Sets the moderation status of one or more comments.

Request parameters:

id - Modifies the moderation status of the comments with the given IDs

moderationStatus - Specifies the requested moderation status. Note, comments can be in statuses, which are not available through this call. For example, this call does not allow to mark a comment as 'likely spam'. Valid values: 'heldForReview', 'published' or 'rejected'. Possible string values are:

  • "published" : The comment is available for public display.
  • "heldForReview" : The comment is awaiting review by a moderator.
  • "likelySpam"
  • "rejected" : The comment is unfit for display.

banAuthor - If set to true the author of the comment gets added to the ban list. This means all future comments of the author will autmomatically be rejected. Only valid in combination with STATUS_REJECTED.

$fields - Selector specifying which fields to include in a partial response.

Completes with a commons.ApiRequestError if the API endpoint returned an error.

If the used http.Client completes with an error when making a REST call, this method will complete with the same error.

Implementation

async.Future<void> setModerationStatus(
  core.List<core.String> id,
  core.String moderationStatus, {
  core.bool? banAuthor,
  core.String? $fields,
}) async {
  if (id.isEmpty) {
    throw core.ArgumentError('Parameter id cannot be empty.');
  }
  final queryParams_ = <core.String, core.List<core.String>>{
    'id': id,
    'moderationStatus': [moderationStatus],
    if (banAuthor != null) 'banAuthor': ['${banAuthor}'],
    if ($fields != null) 'fields': [$fields],
  };

  const url_ = 'youtube/v3/comments/setModerationStatus';

  await _requester.request(
    url_,
    'POST',
    queryParams: queryParams_,
    downloadOptions: null,
  );
}