listMailboxDeliveryEvents method

Future<MailboxDeliveryEventsPage> listMailboxDeliveryEvents({
  1. required String projectId,
  2. required String address,
  3. required String deliveryId,
  4. int count = 100,
  5. int offset = 0,
})

Implementation

Future<MailboxDeliveryEventsPage> listMailboxDeliveryEvents({
  required String projectId,
  required String address,
  required String deliveryId,
  int count = 100,
  int offset = 0,
}) async {
  final encodedProjectId = Uri.encodeComponent(projectId);
  final encodedAddress = Uri.encodeComponent(address);
  final encodedDeliveryId = Uri.encodeComponent(deliveryId);
  final query = <String, String>{'count': '$count', 'offset': '$offset'};
  final uri = Uri.parse(
    '$baseUrl/accounts/projects/$encodedProjectId/mailboxes/$encodedAddress/deliveries/$encodedDeliveryId/events',
  ).replace(queryParameters: query);
  final response = await httpClient.get(uri);
  if (response.statusCode >= 400) {
    throw MeshagentException(
      'Failed to list mailbox delivery events. '
      'Status code: ${response.statusCode}, body: ${response.body}',
    );
  }
  return MailboxDeliveryEventsPage.fromJson(jsonDecode(response.body) as Map<String, dynamic>);
}