list method

Future<ListDraftsResponse> list(
  1. String userId, {
  2. bool? includeSpamTrash,
  3. int? maxResults,
  4. String? pageToken,
  5. String? q,
  6. String? $fields,
})

Lists the drafts in the user's mailbox.

Request parameters:

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

includeSpamTrash - Include drafts from SPAM and TRASH in the results.

maxResults - Maximum number of drafts to return. This field defaults to 100. The maximum allowed value for this field is 500.

pageToken - Page token to retrieve a specific page of results in the list.

q - Only return draft messages matching the specified query. Supports the same query format as the Gmail search box. For example, "from:someuser@example.com rfc822msgid: is:unread".

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

Completes with a ListDraftsResponse.

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<ListDraftsResponse> list(
  core.String userId, {
  core.bool? includeSpamTrash,
  core.int? maxResults,
  core.String? pageToken,
  core.String? q,
  core.String? $fields,
}) async {
  final queryParams_ = <core.String, core.List<core.String>>{
    if (includeSpamTrash != null) 'includeSpamTrash': ['${includeSpamTrash}'],
    if (maxResults != null) 'maxResults': ['${maxResults}'],
    if (pageToken != null) 'pageToken': [pageToken],
    if (q != null) 'q': [q],
    if ($fields != null) 'fields': [$fields],
  };

  final url_ =
      'gmail/v1/users/' + commons.escapeVariable('$userId') + '/drafts';

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