searchEmails method

Future<SearchEmailsResponse?> searchEmails(
  1. String q, {
  2. List<String>? accountIds,
  3. List<String>? providers,
  4. String? xWorkspaceID,
  5. String? from,
  6. String? to,
  7. String? subject,
  8. bool? hasAttachment,
  9. bool? isUnread,
  10. bool? isStarred,
  11. List<String>? labels,
  12. DateTime? after,
  13. DateTime? before,
  14. int? limit,
  15. String? nextPageToken,
})

Structured search across connected mail accounts.

Fan-out search. Mirrors listEmails's account/provider filter semantics. Date range filters are inclusive. The query string itself is passed via ?q= (not ?query=); structured filters go in their own params.

Parameters:

  • String q (required): Provider-specific full-text query string.

  • List<String> accountIds: Repeatable. Restrict to these connected-account row ids. Mutually orthogonal to providers — when both are set the intersection is used.

  • List<String> providers: Repeatable. Restrict to these provider ids (gmail, outlook).

  • String xWorkspaceID: Workspace scope for unscoped tokens. Workspace-scoped PATs and OAuth tokens carry this implicitly; for session/JWT auth without a scoped PAT, pass it explicitly.

  • String from:

  • String to:

  • String subject:

  • bool hasAttachment:

  • bool isUnread:

  • bool isStarred:

  • List<String> labels:

  • DateTime after: Inclusive lower-bound date.

  • DateTime before: Inclusive upper-bound date.

  • int limit:

  • String nextPageToken: Cursor returned by the previous call.

Implementation

Future<SearchEmailsResponse?> searchEmails(String q, { List<String>? accountIds, List<String>? providers, String? xWorkspaceID, String? from, String? to, String? subject, bool? hasAttachment, bool? isUnread, bool? isStarred, List<String>? labels, DateTime? after, DateTime? before, int? limit, String? nextPageToken, }) async {
  final response = await searchEmailsWithHttpInfo(q,  accountIds: accountIds, providers: providers, xWorkspaceID: xWorkspaceID, from: from, to: to, subject: subject, hasAttachment: hasAttachment, isUnread: isUnread, isStarred: isStarred, labels: labels, after: after, before: before, limit: limit, nextPageToken: nextPageToken, );
  if (response.statusCode >= HttpStatus.badRequest) {
    throw ApiException(response.statusCode, await _decodeBodyBytes(response));
  }
  // When a remote server returns no body with a status of 204, we shall not decode it.
  // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
  // FormatException when trying to decode an empty string.
  if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
    return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'SearchEmailsResponse',) as SearchEmailsResponse;

  }
  return null;
}