Skip to content
Snippets Groups Projects
Commit 1491d459 authored by Sibidharan's avatar Sibidharan :speech_balloon:
Browse files

Finalize APIs & included postman collection update

parent 640189e7
No related branches found
No related tags found
No related merge requests found
...@@ -480,7 +480,7 @@ ...@@ -480,7 +480,7 @@
"formdata": [ "formdata": [
{ {
"key": "refresh_token", "key": "refresh_token",
"value": "b0d4dea4685b4b9a47de06fa2bdb3b07705cef2548894455a81b3aab59544684", "value": "r.786906ede70648bccc44af4d13a461f87e0331d080565fbe1fd2ac21ea2e524c",
"type": "text" "type": "text"
} }
] ]
......
...@@ -94,8 +94,16 @@ class API extends REST { ...@@ -94,8 +94,16 @@ class API extends REST {
$data = [ $data = [
"error" => $e->getMessage() "error" => $e->getMessage()
]; ];
$response_code = 400;
if($e->getMessage() == "Expired token" || $e->getMessage() == "Unauthorized"){
$response_code = 403;
}
if($e->getMessage() == "Not found"){
$response_code = 404;
}
$data = $this->json($data); $data = $this->json($data);
$this->response($data,400); $this->response($data,$response_code);
} }
public function __call($method, $args){ public function __call($method, $args){
......
...@@ -57,7 +57,7 @@ class Folder extends Share{ ...@@ -57,7 +57,7 @@ class Folder extends Share{
$this->data = mysqli_fetch_assoc($result); $this->data = mysqli_fetch_assoc($result);
$this->id = $this->data['id']; $this->id = $this->data['id'];
} else { } else {
throw new Exception("Folder not found: ".mysqli_error($this->db)); throw new Exception("Not found");
} }
} }
} }
...@@ -75,7 +75,7 @@ class Folder extends Share{ ...@@ -75,7 +75,7 @@ class Folder extends Share{
$this->refresh(); $this->refresh();
return $result; return $result;
} else { } else {
throw new Exception("Note not loaded"); throw new Exception("Not found");
} }
} }
...@@ -120,10 +120,10 @@ class Folder extends Share{ ...@@ -120,10 +120,10 @@ class Folder extends Share{
$result = mysqli_query($this->db, $query); $result = mysqli_query($this->db, $query);
return $result; return $result;
} else { } else {
throw new Exception("Folder not loaded"); throw new Exception("Not found");
} }
} else { } else {
throw new Exception("Unable to delete"); throw new Exception("Unauthorized");
} }
} }
...@@ -137,6 +137,8 @@ class Folder extends Share{ ...@@ -137,6 +137,8 @@ class Folder extends Share{
$date = $data[$i]['created_at']; $date = $data[$i]['created_at'];
$c = new Carbon($date); $c = new Carbon($date);
$data[$i]['created'] = $c->diffForHumans(); $data[$i]['created'] = $c->diffForHumans();
$f = new Folder($data[$i]['id']);
$data[$i]['count'] = $f->countNotes();
} }
return $data; return $data;
} else { } else {
......
...@@ -20,11 +20,11 @@ class Notes extends Share{ ...@@ -20,11 +20,11 @@ class Notes extends Share{
if($this->id != null){ if($this->id != null){
$query = "SELECT * FROM notes WHERE id=$this->id"; $query = "SELECT * FROM notes WHERE id=$this->id";
$result = mysqli_query($this->db, $query); $result = mysqli_query($this->db, $query);
if($result){ if($result && mysqli_num_rows($result) == 1){
$this->data = mysqli_fetch_assoc($result); $this->data = mysqli_fetch_assoc($result);
$this->id = $this->data['id']; $this->id = $this->data['id'];
} else { } else {
throw new Exception("Note not found"); throw new Exception("Not found");
} }
} }
} }
...@@ -80,7 +80,7 @@ class Notes extends Share{ ...@@ -80,7 +80,7 @@ class Notes extends Share{
$this->refresh(); $this->refresh();
return $result; return $result;
} else { } else {
throw new Exception("Note not loaded"); throw new Exception("Not found");
} }
} else { } else {
throw new Exception("Unauthorized"); throw new Exception("Unauthorized");
...@@ -96,7 +96,7 @@ class Notes extends Share{ ...@@ -96,7 +96,7 @@ class Notes extends Share{
$this->refresh(); $this->refresh();
return $result; return $result;
} else { } else {
throw new Exception("Note not loaded"); throw new Exception("Not found");
} }
} else { } else {
throw new Exception("Unauthorized"); throw new Exception("Unauthorized");
...@@ -116,7 +116,7 @@ class Notes extends Share{ ...@@ -116,7 +116,7 @@ class Notes extends Share{
throw new Exception("Something is not right"); throw new Exception("Something is not right");
} }
} else { } else {
throw new Exception("Note not loaded"); throw new Exception("Not found");
} }
} else { } else {
throw new Exception("Unauthorized"); throw new Exception("Unauthorized");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment