add crud api global setting and make global api response and handle response web and api on bootstrap app
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
use App\Helpers\ApiResponse;
|
||||
use App\Traits\GlobalApiResponse;
|
||||
use GuzzleHttp\Client;
|
||||
use Exception;
|
||||
class ServiceClient
|
||||
{
|
||||
use GlobalApiResponse;
|
||||
private $client;
|
||||
private $baseUrl;
|
||||
private $headers;
|
||||
@@ -41,9 +42,9 @@ class ServiceClient
|
||||
$response = $this->client->request($method, $this->baseUrl . $url, $options);
|
||||
|
||||
$resultResponse = json_decode($response->getBody(), true);
|
||||
return ApiResponse::successResponse($resultResponse, "Successfully fetched data");
|
||||
return $this->resSuccess($resultResponse);
|
||||
} catch (Exception $e) {
|
||||
return ApiResponse::errorResponse($e->getMessage(), $e->getCode());
|
||||
return $this->resError($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user