updateScheduledTask method

Future<void> updateScheduledTask({
  1. required String projectId,
  2. required String taskId,
  3. String? roomName,
  4. String? queueName,
  5. dynamic payload,
  6. String? schedule,
  7. bool? active,
  8. Map<String, String> annotations = const {},
})

PUT /accounts/projects/{project_id}/scheduled-tasks/{task_id}

Implementation

Future<void> updateScheduledTask({
  required String projectId,
  required String taskId,
  String? roomName,
  String? queueName,
  dynamic payload,
  String? schedule,
  bool? active,
  Map<String, String> annotations = const {},
}) async {
  final encodedProjectId = Uri.encodeComponent(projectId);
  final encodedTaskId = Uri.encodeComponent(taskId);
  final uri = Uri.parse('$baseUrl/accounts/projects/$encodedProjectId/scheduled-tasks/$encodedTaskId');
  final body = _UpdateScheduledTaskRequest(
    roomName: roomName,
    queueName: queueName,
    payload: payload,
    schedule: schedule,
    active: active,
    annotations: annotations,
  ).toJson();

  final resp = await httpClient.put(uri, body: jsonEncode(body));

  if (resp.statusCode >= 400) {
    throw MeshagentException('Failed to update scheduled task. Status code: ${resp.statusCode}, body: ${resp.body}');
  }
}