listRecentSessions method
Corresponds to: GET /accounts/projects/{project_id}/sessions
Returns a JSON dict: { "sessions": ... }
Implementation
Future<List<RoomSession>> listRecentSessions(String projectId) async {
final uri = Uri.parse('$baseUrl/accounts/projects/$projectId/sessions');
final response = await http.get(uri, headers: _getHeaders());
if (response.statusCode >= 400) {
throw MeshagentException(
'Failed to list recent sessions. '
'Status code: ${response.statusCode}, body: ${response.body}',
);
}
final data = jsonDecode(response.body) as Map<String, dynamic>;
final list = data['sessions'] as List<dynamic>? ?? [];
return list.whereType<Map<String, dynamic>>().map(RoomSession.fromJson).toList();
}