add crud api global setting and make global api response and handle response web and api on bootstrap app
This commit is contained in:
@@ -3,17 +3,18 @@
|
||||
namespace App;
|
||||
|
||||
use App\Enums\ImportDatasourceStatus;
|
||||
use App\Helpers\ApiResponse;
|
||||
use App\Models\ImportDatasource;
|
||||
use App\Models\PbgTaskIndexIntegrations;
|
||||
use App\Models\PbgTaskPrasarana;
|
||||
use App\Models\PbgTaskRetributions;
|
||||
use Exception;
|
||||
use App\Models\PbgTask;
|
||||
use App\Traits\GlobalApiResponse;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class ServiceSIMBG
|
||||
{
|
||||
use GlobalApiResponse;
|
||||
private $email;
|
||||
private $password;
|
||||
/**
|
||||
@@ -106,7 +107,7 @@ class ServiceSIMBG
|
||||
'status' => ImportDatasourceStatus::Failed->value,
|
||||
'message' => 'Failed to retrive token'
|
||||
]);
|
||||
return ApiResponse::errorResponse("Failed to retrieve token", 401);
|
||||
return $this->resError("Failed to retrive token");
|
||||
}
|
||||
|
||||
$apiToken = $resToken->original['data']['token']['access'];
|
||||
@@ -127,7 +128,7 @@ class ServiceSIMBG
|
||||
'status' => ImportDatasourceStatus::Failed->value,
|
||||
'message' => 'Invalid response: no total_page'
|
||||
]);
|
||||
return ApiResponse::errorResponse("Invalid response from API", 400);
|
||||
return $this->resError("Invalid response from API");
|
||||
}
|
||||
|
||||
$totalPage = $initialResponse->original['data']['total_page'];
|
||||
@@ -214,7 +215,7 @@ class ServiceSIMBG
|
||||
]);
|
||||
|
||||
Log::info("syncTaskList completed", $result);
|
||||
return ApiResponse::successResponse(json_encode($result), "Successfully saved");
|
||||
return $this->resSuccess($result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user