Skip to content

Commit c41e75c

Browse files
committed
Changed inconsistency of return response
Using standard status and message
1 parent 9dbaac8 commit c41e75c

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

application/controllers/api/Example.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function users_get()
5656
// Set the response and exit
5757
$this->response([
5858
'status' => FALSE,
59-
'error' => 'No users were found'
59+
'message' => 'No users were found'
6060
], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
6161
}
6262
}
@@ -96,7 +96,7 @@ public function users_get()
9696
{
9797
$this->set_response([
9898
'status' => FALSE,
99-
'error' => 'User could not be found'
99+
'message' => 'User could not be found'
100100
], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
101101
}
102102
}

application/controllers/api/Key.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function index_put()
5252
{
5353
$this->response([
5454
'status' => FALSE,
55-
'error' => 'Could not save the key'
55+
'message' => 'Could not save the key'
5656
], REST_Controller::HTTP_INTERNAL_SERVER_ERROR); // INTERNAL_SERVER_ERROR (500) being the HTTP response code
5757
}
5858
}
@@ -73,7 +73,7 @@ public function index_delete()
7373
// It doesn't appear the key exists
7474
$this->response([
7575
'status' => FALSE,
76-
'error' => 'Invalid API key'
76+
'message' => 'Invalid API key'
7777
], REST_Controller::HTTP_BAD_REQUEST); // BAD_REQUEST (400) being the HTTP response code
7878
}
7979

@@ -83,7 +83,7 @@ public function index_delete()
8383
// Respond that the key was destroyed
8484
$this->response([
8585
'status' => TRUE,
86-
'success' => 'API key was deleted'
86+
'message' => 'API key was deleted'
8787
], REST_Controller::HTTP_NO_CONTENT); // NO_CONTENT (204) being the HTTP response code
8888
}
8989

@@ -104,7 +104,7 @@ public function level_post()
104104
// It doesn't appear the key exists
105105
$this->response([
106106
'status' => FALSE,
107-
'error' => 'Invalid API key'
107+
'message' => 'Invalid API key'
108108
], REST_Controller::HTTP_BAD_REQUEST); // BAD_REQUEST (400) being the HTTP response code
109109
}
110110

@@ -113,14 +113,14 @@ public function level_post()
113113
{
114114
$this->response([
115115
'status' => TRUE,
116-
'success' => 'API key was updated'
116+
'message' => 'API key was updated'
117117
], REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
118118
}
119119
else
120120
{
121121
$this->response([
122122
'status' => FALSE,
123-
'error' => 'Could not update the key level'
123+
'message' => 'Could not update the key level'
124124
], REST_Controller::HTTP_INTERNAL_SERVER_ERROR); // INTERNAL_SERVER_ERROR (500) being the HTTP response code
125125
}
126126
}
@@ -141,7 +141,7 @@ public function suspend_post()
141141
// It doesn't appear the key exists
142142
$this->response([
143143
'status' => FALSE,
144-
'error' => 'Invalid API key'
144+
'message' => 'Invalid API key'
145145
], REST_Controller::HTTP_BAD_REQUEST); // BAD_REQUEST (400) being the HTTP response code
146146
}
147147

@@ -150,14 +150,14 @@ public function suspend_post()
150150
{
151151
$this->response([
152152
'status' => TRUE,
153-
'success' => 'Key was suspended'
153+
'message' => 'Key was suspended'
154154
], REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
155155
}
156156
else
157157
{
158158
$this->response([
159159
'status' => FALSE,
160-
'error' => 'Could not suspend the user'
160+
'message' => 'Could not suspend the user'
161161
], REST_Controller::HTTP_INTERNAL_SERVER_ERROR); // INTERNAL_SERVER_ERROR (500) being the HTTP response code
162162
}
163163
}
@@ -179,7 +179,7 @@ public function regenerate_post()
179179
// It doesn't appear the key exists
180180
$this->response([
181181
'status' => FALSE,
182-
'error' => 'Invalid API key'
182+
'message' => 'Invalid API key'
183183
], REST_Controller::HTTP_BAD_REQUEST); // BAD_REQUEST (400) being the HTTP response code
184184
}
185185

@@ -201,7 +201,7 @@ public function regenerate_post()
201201
{
202202
$this->response([
203203
'status' => FALSE,
204-
'error' => 'Could not save the key'
204+
'message' => 'Could not save the key'
205205
], REST_Controller::HTTP_INTERNAL_SERVER_ERROR); // INTERNAL_SERVER_ERROR (500) being the HTTP response code
206206
}
207207
}

0 commit comments

Comments
 (0)