getEmails method

Future<List<EmailPreview>?> getEmails(
  1. String inboxId, {
  2. int? size,
  3. int? limit,
  4. String? sort,
  5. int? retryTimeout,
  6. int? delayTimeout,
  7. int? minCount,
  8. bool? unreadOnly,
  9. DateTime? before,
  10. DateTime? since,
})

Get emails in an Inbox. This method is not idempotent as it allows retries and waits if you want certain conditions to be met before returning. For simple listing and sorting of known emails use the email controller instead.

List emails that an inbox has received. Only emails that are sent to the inbox's email address will appear in the inbox. It may take several seconds for any email you send to an inbox's email address to appear in the inbox. To make this endpoint wait for a minimum number of emails use the minCount parameter. The server will retry the inbox database until the minCount is satisfied or the retryTimeout is reached

Parameters:

  • String inboxId (required): Id of inbox that emails belongs to

  • int size: Alias for limit. Assessed first before assessing any passed limit.

  • int limit: Limit the result set, ordered by received date time sort direction. Maximum 100. For more listing options see the email controller

  • String sort: Sort the results by received date and direction ASC or DESC

  • int retryTimeout: Maximum milliseconds to spend retrying inbox database until minCount emails are returned

  • int delayTimeout:

  • int minCount: Minimum acceptable email count. Will cause request to hang (and retry) until minCount is satisfied or retryTimeout is reached.

  • bool unreadOnly:

  • DateTime before: Exclude emails received after this ISO 8601 date time

  • DateTime since: Exclude emails received before this ISO 8601 date time

Implementation

Future<List<EmailPreview>?> getEmails(String inboxId, { int? size, int? limit, String? sort, int? retryTimeout, int? delayTimeout, int? minCount, bool? unreadOnly, DateTime? before, DateTime? since, }) async {
  final response = await getEmailsWithHttpInfo(inboxId,  size: size, limit: limit, sort: sort, retryTimeout: retryTimeout, delayTimeout: delayTimeout, minCount: minCount, unreadOnly: unreadOnly, before: before, since: since, );
  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) {
    final responseBody = await _decodeBodyBytes(response);
    return (await apiClient.deserializeAsync(responseBody, 'List<EmailPreview>') as List)
      .cast<EmailPreview>()
      .toList();

  }
  return null;
}