list method

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

Lists the messages 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 messages from SPAM and TRASH in the results.

labelIds - Only return messages with labels that match all of the specified label IDs. Messages in a thread might have labels that other messages in the same thread don't have. To learn more, see Manage labels on messages and threads.

maxResults - Maximum number of messages 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 messages matching the specified query. Supports the same query format as the Gmail search box. For example, "from:someuser@example.com rfc822msgid: is:unread". Parameter cannot be used when accessing the api using the gmail.metadata scope.

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

Completes with a ListMessagesResponse.

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<ListMessagesResponse> list(
  core.String userId, {
  core.bool? includeSpamTrash,
  core.List<core.String>? labelIds,
  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 (labelIds != null) 'labelIds': labelIds,
    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') + '/messages';

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