getMailboxDelivery method

Future<MailboxDelivery> getMailboxDelivery({
  1. required String projectId,
  2. required String address,
  3. required String deliveryId,
})

Implementation

Future<MailboxDelivery> getMailboxDelivery({required String projectId, required String address, required String deliveryId}) async {
  final encodedProjectId = Uri.encodeComponent(projectId);
  final encodedAddress = Uri.encodeComponent(address);
  final encodedDeliveryId = Uri.encodeComponent(deliveryId);
  final uri = Uri.parse('$baseUrl/accounts/projects/$encodedProjectId/mailboxes/$encodedAddress/deliveries/$encodedDeliveryId');
  final response = await httpClient.get(uri);
  if (response.statusCode == 404) throw NotFoundException('Mailbox delivery not found: $deliveryId');
  if (response.statusCode >= 400) {
    throw MeshagentException(
      'Failed to get mailbox delivery. '
      'Status code: ${response.statusCode}, body: ${response.body}',
    );
  }
  final data = jsonDecode(response.body) as Map<String, dynamic>;
  return MailboxDelivery.fromJson(data['delivery'] as Map<String, dynamic>);
}