-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ead6aa3
commit 861f852
Showing
4 changed files
with
150 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
|
||
namespace Firebit\Laravel\ApiResponse; | ||
|
||
|
||
class ApiResponseTypes | ||
{ | ||
/** | ||
* @param null $data | ||
* @param int $status_code | ||
* @return ApiResponse | ||
*/ | ||
static public function success($data = null, int $status_code = ApiResponseCode::HTTP_SUCCESS){ | ||
$response = ApiResponse::create($data, $status_code); | ||
return $response; | ||
} | ||
|
||
/** | ||
* @param $data | ||
* @param int $status_code | ||
* @return ApiResponse | ||
*/ | ||
static public function fail($data, int $status_code = ApiResponseCode::HTTP_ERROR_CLIENT_NOT_ACCEPTABLE){ | ||
$response = ApiResponse::create($data, $status_code); | ||
return $response; | ||
} | ||
|
||
/** | ||
* @param $message | ||
* @param int $status_code | ||
* @return ApiResponse | ||
*/ | ||
static public function error($message, int $status_code = ApiResponseCode::HTTP_ERROR_SERVER_INTERNAL){ | ||
$response = ApiResponse::create(null, $status_code); | ||
$response->setErrorMessage($message); | ||
return $response; | ||
} | ||
} |