batchUpdate method

Future<BatchUpdateDocumentResponse> batchUpdate(
  1. BatchUpdateDocumentRequest request,
  2. String documentId, {
  3. String? $fields,
})

Applies one or more updates to the document.

Each request is validated before being applied. If any request is not valid, then the entire request will fail and nothing will be applied. Some requests have replies to give you some information about how they are applied. Other requests do not need to return information; these each return an empty reply. The order of replies matches that of the requests. For example, suppose you call batchUpdate with four updates, and only the third one returns information. The response would have two empty replies, the reply to the third request, and another empty reply, in that order. Because other users may be editing the document, the document might not exactly reflect your changes: your changes may be altered with respect to collaborator changes. If there are no collaborators, the document should reflect your changes. In any case, the updates in your request are guaranteed to be applied together atomically.

request - The metadata request object.

Request parameters:

documentId - The ID of the document to update.

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

Completes with a BatchUpdateDocumentResponse.

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<BatchUpdateDocumentResponse> batchUpdate(
  BatchUpdateDocumentRequest request,
  core.String documentId, {
  core.String? $fields,
}) async {
  final body_ = convert.json.encode(request);
  final queryParams_ = <core.String, core.List<core.String>>{
    if ($fields != null) 'fields': [$fields],
  };

  final url_ = 'v1/documents/' +
      commons.escapeVariable('$documentId') +
      ':batchUpdate';

  final response_ = await _requester.request(
    url_,
    'POST',
    body: body_,
    queryParams: queryParams_,
  );
  return BatchUpdateDocumentResponse.fromJson(
      response_ as core.Map<core.String, core.dynamic>);
}