commit fbfc906f27e5503870f69bdc8f46b91362544564
parent a686130ea12783e312ac1dae532ae612ae2b1e0b
Author: MTRNord <mtrnord1@gmail.com>
Date: Wed, 18 Mar 2015 19:21:39 +0100
add missing api endpoint
Diffstat:
1 file changed, 29 insertions(+), 0 deletions(-)
diff --git a/core/api/v1/api.php b/core/api/v1/api.php
@@ -169,6 +169,35 @@ $app->get('/posts/:id', function($task_id) {
}
});
+/**
+* Listing all posts
+* method GET
+* url /posts/
+* Will return 404 if the task doesn't belongs to user
+*/
+$app->get('/posts/', function() {
+ global $user_id;
+ $response = array();
+ $db = new DbHandler();
+
+ // fetch task
+ $result = $db->getTask($task_id, $user_id);
+
+ if ($result != NULL) {
+ $response["error"] = false;
+ $response["id"] = $result["id"];
+ $response["task"] = $result["task"];
+ $response["status"] = $result["status"];
+ $response["createdAt"] = $result["created_at"];
+ echoRespnse(200, $response);
+ } else {
+ echo $response;
+ $response["error"] = true;
+ $response["message"] = "The requested resource doesn't exists";
+ echoRespnse(200, $response);
+ }
+});
+
/*
* ------------------------ METHODS WITH AUTHENTICATION ------------------------
*/