Skip to content

Commit 439d4b8

Browse files
committed
Added code 201 Created and 202 Accepted
1 parent 1fbf876 commit 439d4b8

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

readme.md

+11-9
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,16 @@ Default functions that returns a specific http code, but in the same way the bod
122122

123123
|Function |Description |
124124
|--------------------------------|-------------------------------------------------|
125-
|**Ok** | Response status "error" with HTTP 200 |
126-
|**BadRequest** | Response status "error" with HTTP 400 |
127-
|**Unauthorized** | Response status "error" with HTTP 401 |
128-
|**Forbidden** | Response status "error" with HTTP 403 |
129-
|**NotFound** | Response status "error" with HTTP 404 |
130-
|**InternalServerError** | Response status "error" with HTTP 500 |
131-
|**NotImplemented** | Response status "error" with HTTP 501 |
132-
|**BadGateway** | Response status "error" with HTTP 502 |
125+
|**Ok**| Response status "error" with HTTP 200 |
126+
|**Created**| Response status "error" with HTTP 201 |
127+
|**Accepted**| Response status "error" with HTTP 202 |
128+
|**BadRequest**| Response status "error" with HTTP 400 |
129+
|**Unauthorized**| Response status "error" with HTTP 401 |
130+
|**Forbidden**| Response status "error" with HTTP 403 |
131+
|**NotFound**| Response status "error" with HTTP 404 |
132+
|**InternalServerError**| Response status "error" with HTTP 500 |
133+
|**NotImplemented**| Response status "error" with HTTP 501 |
134+
|**BadGateway**| Response status "error" with HTTP 502 |
133135

134136
#### Examples
135137

@@ -156,7 +158,7 @@ Status Code: 404 Not Found
156158
##### 401 Error example
157159
``` php
158160
//Execution in php
159-
return ApiResponse::Unauthorized(null);
161+
return ApiResponse::Unauthorized();
160162
```
161163

162164
``` json

src/ApiResponse.php

+10
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ public static function Ok($data = null, $message = null)
3737
return response()->json(Format::Response(self::STATUS_ERROR, self::CODE_200, $message, $data), 200);
3838
}
3939

40+
public static function Created($data = null, $message = null)
41+
{
42+
return response()->json(Format::Response(self::STATUS_ERROR, self::CODE_201, $message, $data), 201);
43+
}
44+
45+
public static function Accepted($data = null, $message = null)
46+
{
47+
return response()->json(Format::Response(self::STATUS_ERROR, self::CODE_202, $message, $data), 202);
48+
}
49+
4050
// ERRORS 40*
4151
public static function BadRequest($data = null, $message = null)
4252
{

0 commit comments

Comments
 (0)