listMailboxesPage method

Future<MailboxesPage> listMailboxesPage(
  1. String projectId, {
  2. int count = 100,
  3. int offset = 0,
  4. String? filter,
})

GET /accounts/projects/{project_id}/mailboxes Returns { "mailboxes": { "address","room","queue" }, ... }

Implementation

Future<MailboxesPage> listMailboxesPage(String projectId, {int count = 100, int offset = 0, String? filter}) async {
  final encodedProjectId = Uri.encodeComponent(projectId);
  final query = <String, String>{'count': '$count', 'offset': '$offset'};
  if (filter != null && filter.trim().isNotEmpty) query['filter'] = filter;
  final uri = Uri.parse('$baseUrl/accounts/projects/$encodedProjectId/mailboxes').replace(queryParameters: query);
  final response = await httpClient.get(uri);

  if (response.statusCode >= 400) {
    throw MeshagentException(
      'Failed to list mailboxes. '
      'Status code: ${response.statusCode}, body: ${response.body}',
    );
  }

  final data = jsonDecode(response.body) as Map<String, dynamic>;
  return MailboxesPage.fromJson(data);
}