mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/izyim.git
synced 2026-09-01 10:53:58 +00:00
large commit
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\Processors;
|
||||
|
||||
use App\Classes\Modules\ControllerLogic\Exceptions\InternalServerErrorException;
|
||||
use App\Classes\Modules\Orders\DataTransferObjects\OrderObject;
|
||||
use App\Classes\Modules\Orders\DataTransferObjects\StepObject;
|
||||
use App\Classes\Modules\Orders\Services\Steps\CompletesOrderStep;
|
||||
use App\Classes\ValueObjects\Constants\HttpStatus;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
abstract class AbstractStepProcessor
|
||||
{
|
||||
|
||||
abstract function validator(): bool;
|
||||
|
||||
abstract function execute(): JsonResponse;
|
||||
|
||||
/**
|
||||
* @param OrderObject $order
|
||||
* @param StepObject $step
|
||||
* @return JsonResponse
|
||||
* @throws InternalServerErrorException
|
||||
*/
|
||||
public function handler(OrderObject $order, StepObject $step) {
|
||||
try {
|
||||
|
||||
if(!$this->validator()){
|
||||
return new JsonResponse(['message' => 'Updating step validation has failed due to missing requirements'], HttpStatus::VALIDATION_FAILED);
|
||||
}
|
||||
|
||||
(new CompletesOrderStep())->execute($order, $step);
|
||||
|
||||
/** notification */
|
||||
|
||||
|
||||
return new JsonResponse(null, HttpStatus::REQUEST_ACCEPTED);
|
||||
|
||||
} catch (\Exception $exception){
|
||||
|
||||
throw new InternalServerErrorException("Failed to update order step because {$exception->getMessage()}");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user