listRoomGrantsByUser method
GET /accounts/projects/{project_id}/room-grants/by-user/{user_id}?limit=&offset=&order_by=
Implementation
Future<List<ProjectRoomGrant>> listRoomGrantsByUser({
required String projectId,
required String userId,
int limit = 50,
int offset = 0,
String orderBy = 'room_name',
}) async {
final u = Uri.encodeComponent(userId);
var uri = Uri.parse(
'$baseUrl/accounts/projects/$projectId/room-grants/by-user/$u',
).replace(queryParameters: {'limit': '$limit', 'offset': '$offset', 'order_by': orderBy});
final response = await http.get(uri, headers: _getHeaders());
if (response.statusCode >= 400) {
throw MeshagentException(
'Failed to list room grants by user. '
'Status code: ${response.statusCode}, body: ${response.body}',
);
}
final data = jsonDecode(response.body) as Map<String, dynamic>;
final list = data['room_grants'] as List<dynamic>? ?? [];
return list.whereType<Map<String, dynamic>>().map(ProjectRoomGrant.fromJson).toList();
}