listUniqueUsersWithGrantsPage method

Future<ProjectUserGrantCountsPage> listUniqueUsersWithGrantsPage({
  1. required String projectId,
  2. int limit = 100,
  3. int offset = 0,
  4. String? filter,
})

GET /accounts/projects/{project_id}/room-grants/by-user?limit=&offset=

Implementation

Future<ProjectUserGrantCountsPage> listUniqueUsersWithGrantsPage({
  required String projectId,
  int limit = 100,
  int offset = 0,
  String? filter,
}) async {
  final encodedProjectId = Uri.encodeComponent(projectId);
  final query = <String, String>{'limit': '$limit', 'offset': '$offset'};
  if (filter != null && filter.trim().isNotEmpty) query['filter'] = filter;
  final uri = Uri.parse('$baseUrl/accounts/projects/$encodedProjectId/room-grants/by-user').replace(queryParameters: query);
  final response = await httpClient.get(uri);

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

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