mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/izyim.git
synced 2026-08-27 16:33:57 +00:00
large commit
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\ControllersLogic\Orders\PackingList;
|
||||
|
||||
use App\Classes\Modules\ControllerLogic\Exceptions\InternalServerErrorException;
|
||||
use App\Classes\Modules\Orders\DataTransferObjects\OrderObject;
|
||||
use App\Classes\Modules\Orders\DataTransferObjects\PackingListObject;
|
||||
use App\Classes\Modules\Orders\Services\PackingList\UpdatesPackingList;
|
||||
use App\Classes\ValueObjects\Constants\HttpStatus;
|
||||
use App\Traits\ChecksIfPackingListIsComplete;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdatePackingListLogic
|
||||
{
|
||||
|
||||
use ChecksIfPackingListIsComplete;
|
||||
|
||||
/** @var UpdatesPackingList */
|
||||
private $updatesPackingList;
|
||||
|
||||
/**
|
||||
* UpdatePackingListLogic constructor.
|
||||
* @param UpdatesPackingList $updatesPackingList
|
||||
*/
|
||||
public function __construct(UpdatesPackingList $updatesPackingList)
|
||||
{
|
||||
$this->updatesPackingList = $updatesPackingList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param String $orderId
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws InternalServerErrorException
|
||||
*/
|
||||
public function execute(String $orderId, Request $request){
|
||||
|
||||
try {
|
||||
|
||||
$orderObject = new OrderObject($orderId);
|
||||
|
||||
$packingListObject = new PackingListObject($request->input('reference_no'), $request->input('packages'));
|
||||
|
||||
$confirmed = $this->checkPackingListIsComplete($packingListObject->getPackages());
|
||||
|
||||
$this->updatesPackingList->execute($orderObject, $packingListObject, $confirmed);
|
||||
|
||||
return new JsonResponse(null, HttpStatus::RESOURCE_CREATED);
|
||||
|
||||
} catch (\Exception $exception){
|
||||
throw new InternalServerErrorException("Failed to update order's packing list because {$exception->getMessage()}");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user