Skip to content

Commit 804da1f

Browse files
committed
Merge pull request #5 from dennisoderwald/master
Added: 'delete' Handler for request / 'deleteTask' function to delete a task
2 parents be23d97 + a2594e5 commit 804da1f

File tree

2 files changed

+63
-1
lines changed

2 files changed

+63
-1
lines changed

src/Torann/LaravelAsana/Asana.php

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public function getTask($taskId)
123123
*/
124124
public function getSubTasks($taskId)
125125
{
126-
return $this->curl->get("tasks/{$taskId}/subtasks");
126+
return $this->curl->get("tasks/{$taskId}/subtasks");
127127
}
128128

129129
/**
@@ -138,6 +138,17 @@ public function updateTask($taskId, $data)
138138
return $this->curl->put("tasks/{$taskId}", array('data' => $data));
139139
}
140140

141+
/**
142+
* Delete a task
143+
*
144+
* @param string $taskId
145+
* @return string JSON or null
146+
*/
147+
public function deleteTask($taskId)
148+
{
149+
return $this->curl->delete("tasks/{$taskId}");
150+
}
151+
141152
/**
142153
* Add Attachment to a task
143154
*
@@ -534,6 +545,29 @@ public function getWorkspaceUsers($workspaceId = null)
534545
return $this->curl->get("workspaces/{$workspaceId}/users");
535546
}
536547

548+
/**
549+
* Returns events of a given project
550+
*
551+
* @param string $projectId The id of the project
552+
* @return string JSON or null
553+
*/
554+
public function getProjectEvents($projectId = null)
555+
{
556+
$projectId = $projectId ?: $this->defaultProjectId;
557+
558+
return $this->curl->get("projects/{$projectId}/events");
559+
}
560+
561+
/**
562+
* Return event sync key
563+
*
564+
* @return mixed
565+
*/
566+
public function getSyncKey()
567+
{
568+
return $this->curl->getSyncKey();
569+
}
570+
537571
/**
538572
* Return error
539573
*

src/Torann/LaravelAsana/AsanaCurl.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class AsanaCurl {
2121

2222
private $apiKey;
2323
private $accessToken;
24+
private $syncKey;
2425
private $curl;
2526

2627
/**
@@ -77,6 +78,17 @@ public function put($url, array $data = array())
7778
return $this->request(self::METHOD_PUT, $url, $data);
7879
}
7980

81+
/**
82+
* Delete request
83+
*
84+
* @param string $url
85+
* @param array $data
86+
*/
87+
public function delete($url, array $data = array())
88+
{
89+
return $this->request(self::METHOD_DELETE, $url, $data);
90+
}
91+
8092
/**
8193
* Return error
8294
*
@@ -87,6 +99,16 @@ public function getErrors()
8799
return $this->errors;
88100
}
89101

102+
/**
103+
* Return sync key
104+
*
105+
* @return mixed
106+
*/
107+
public function getSyncKey()
108+
{
109+
return $this->syncKey;
110+
}
111+
90112
/**
91113
* This function communicates with Asana REST API.
92114
* You don't need to call this function directly. It's only for inner class working.
@@ -235,6 +257,12 @@ private function checkForCurlErrors($response)
235257
return $error->message;
236258
}, $response->errors));
237259

260+
// fetch sync key for event handling
261+
if (isset($response->sync))
262+
{
263+
$this->syncKey = $response->sync;
264+
}
265+
238266
throw new Exception($errors, $resultStatus['http_code']);
239267
}
240268

0 commit comments

Comments
 (0)