listScheduledTasks method
GET /accounts/projects/{project_id}/scheduled-tasks?room_name=&task_id=&active=&limit=&offset=
Returns { "tasks": ... }
Implementation
Future<List<ScheduledTask>> listScheduledTasks({
required String projectId,
String? roomName,
String? taskId,
bool? active,
int limit = 200,
int offset = 0,
}) async {
final qp = <String, String>{'limit': '$limit', 'offset': '$offset'};
if (roomName != null) qp['room_name'] = roomName;
if (taskId != null) qp['task_id'] = taskId;
if (active != null) qp['active'] = active ? 'true' : 'false';
final encodedProjectId = Uri.encodeComponent(projectId);
final uri = Uri.parse('$baseUrl/accounts/projects/$encodedProjectId/scheduled-tasks').replace(queryParameters: qp);
final resp = await httpClient.get(uri);
if (resp.statusCode >= 400) {
throw MeshagentException('Failed to list scheduled tasks. Status code: ${resp.statusCode}, body: ${resp.body}');
}
final decoded = jsonDecode(resp.body) as Map<String, dynamic>;
final tasksRaw = decoded['tasks'];
if (tasksRaw is! List) {
throw MeshagentException("Invalid scheduled-tasks payload: expected 'tasks' to be a list");
}
return tasksRaw.whereType<Map>().map((m) => ScheduledTask.fromJson(m.cast<String, dynamic>())).toList();
}