Skip to content

Commit

Permalink
Several new API calls.
Browse files Browse the repository at this point in the history
  • Loading branch information
thousandsofthem committed Nov 27, 2011
1 parent fd32265 commit 2c02c0d
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
31 changes: 30 additions & 1 deletion SimpleWorker.class.php
Expand Up @@ -219,7 +219,12 @@ public function deleteTask($project_id, $task_id){
public function deleteSchedule($project_id, $schedule_id){
$this->setProjectId($project_id);
$url = "projects/{$this->project_id}/schedules/$schedule_id";
return $this->apiCall(self::DELETE, $url);

$request = array(
'schedule_id' => $schedule_id
);

return $this->apiCall(self::DELETE, $url, $request);
}

public function getSchedules($project_id){
Expand Down Expand Up @@ -315,6 +320,30 @@ function getLog($project_id, $task_id){
return $this->apiCall(self::GET, $url);
}


function cancelTask($project_id, $task_id){
$url = "projects/$project_id/tasks/$task_id/cancel";
$request = array();

$this->setCommonHeaders();
$res = $this->apiCall(self::POST, $url, $request);
$responce = json_decode($res);
return $responce;
}

function setTaskProgress($project_id, $task_id, $percent, $msg = ''){
$url = "projects/$project_id/tasks/$task_id/progress";
$request = array(
'percent' => $percent,
'msg' => $msg
);

$this->setCommonHeaders();
$res = $this->apiCall(self::POST, $url, $request);
$responce = json_decode($res);
return $responce;
}

/* PRIVATE FUNCTIONS */

private function compiledHeaders(){
Expand Down
14 changes: 14 additions & 0 deletions test.php
Expand Up @@ -57,6 +57,20 @@ function tolog($name, $variable, $display = false){
tolog('delete_task', $res);
*/

echo "\n--Set Task Progress-----------------------------------\n";
$res = $sw->setTaskProgress($projects[0]->id, $task_id, 50, 'Job half-done');
tolog('set_task_progress', $res, true);

/*
echo "\n--Cancel Task-----------------------------------\n";
# TODO: returns {"goto":"http://www.iron.io","version":"2.0.12"}
# or {"msg":"Method POST not allowed","status_code":405}
$res = $sw->cancelTask($projects[0]->id, $task_id);
tolog('cancel_task', $res, true);
*/



# =========================== Codes =============================

echo "\n--Get Codes-------------------------------------------\n";
Expand Down

0 comments on commit 2c02c0d

Please sign in to comment.