getGroupMembersPublicKeys function

Future<List<GroupMemberPublicKey>> getGroupMembersPublicKeys({
  1. required String chatId,
  2. int page = 1,
  3. int limit = 20,
})

Implementation

Future<List<GroupMemberPublicKey>> getGroupMembersPublicKeys({
  required String chatId,
  int page = 1,
  int limit = 20,
}) async {
  if (chatId.isEmpty) {
    throw Exception('chatId cannot be null or empty');
  }

  final result = await http.get(
      path:
          '/v1/chat/groups/$chatId/members/publicKeys?pageNumber=$page&pageSize=$limit');

  if (result == null || result is String) {
    throw Exception(result ??
        'Failed to retrieve public keys for group members. ChatId: $chatId');
  }

  return (result['members'] as List)
      .map((e) => GroupMemberPublicKey.fromJson(e))
      .toList();
}