update method

Future<Draft> update(
  1. Draft request,
  2. String userId,
  3. String id, {
  4. String? $fields,
  5. UploadOptions uploadOptions = commons.UploadOptions.defaultOptions,
  6. Media? uploadMedia,
})

Replaces a draft's content.

request - The metadata request object.

Request parameters:

userId - The user's email address. The special value me can be used to indicate the authenticated user.

id - The ID of the draft to update.

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

uploadMedia - The media to upload.

uploadOptions - Options for the media upload. Streaming Media without the length being known ahead of time is only supported via resumable uploads.

Completes with a Draft.

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<Draft> update(
  Draft request,
  core.String userId,
  core.String id, {
  core.String? $fields,
  commons.UploadOptions uploadOptions = commons.UploadOptions.defaultOptions,
  commons.Media? uploadMedia,
}) async {
  final body_ = convert.json.encode(request);
  final queryParams_ = <core.String, core.List<core.String>>{
    if ($fields != null) 'fields': [$fields],
  };

  core.String url_;
  if (uploadMedia == null) {
    url_ = 'gmail/v1/users/' +
        commons.escapeVariable('$userId') +
        '/drafts/' +
        commons.escapeVariable('$id');
  } else if (uploadOptions is commons.ResumableUploadOptions) {
    url_ = '/resumable/upload/gmail/v1/users/' +
        commons.escapeVariable('$userId') +
        '/drafts/' +
        commons.escapeVariable('$id');
  } else {
    url_ = '/upload/gmail/v1/users/' +
        commons.escapeVariable('$userId') +
        '/drafts/' +
        commons.escapeVariable('$id');
  }

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