getMailboxInfo method

Future<MailboxInfo> getMailboxInfo({
  1. required String folderPath,
  2. required MailboxType type,
})

Get detailed info about a specific mailbox

Implementation

Future<MailboxInfo> getMailboxInfo({
  required String folderPath,
  required MailboxType type,
}) async {
  _logger.fine('Getting info for mailbox: $folderPath');

  final address = MailboxAddress(
    ownerId: host.id,
    folderPath: folderPath,
    type: type,
  );

  final request = GetMailboxInfoRequest(address: address);

  final response = await _sendRequest(request);
  if (!response.success) {
    if (response.errorMessage?.contains('not found') ?? false) {
      throw MailboxNotFound(address.fullPath);
    }
    throw MailboxManagementError(
      response.errorMessage ?? 'Failed to get mailbox info',
    );
  }

  if (response.data == null) {
    throw MailboxManagementError('No data returned for mailbox info');
  }

  return MailboxInfo.fromJson(response.data as Map<String, dynamic>);
}