list method

Future<ListThreadsResponse> 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 threads 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 threads from SPAM and TRASH in the results.

labelIds - Only return threads with labels that match all of the specified label IDs.

maxResults - Maximum number of threads 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 threads 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 ListThreadsResponse.

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<ListThreadsResponse> 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') + '/threads';

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