43 lines
1 KiB
PHP
43 lines
1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Cqs\Actions\Orders;
|
|
|
|
use App\Contracts\Action;
|
|
use App\Contracts\ActionInput;
|
|
use Domain\Services\OrderTunnelService;
|
|
use Webmozart\Assert\Assert;
|
|
|
|
/**
|
|
* @implements \App\Contracts\Action<
|
|
* \App\Cqs\Actions\Orders\ConfirmPlacedOrderInput,
|
|
* \App\Cqs\Actions\Orders\ConfirmPlacedOrderOutput
|
|
* >
|
|
*/
|
|
final class ConfirmPlacedOrder implements Action
|
|
{
|
|
public function __construct(
|
|
private readonly OrderTunnelService $orderTunnelService,
|
|
) {
|
|
}
|
|
|
|
/**
|
|
* @param \App\Cqs\Actions\Orders\ConfirmPlacedOrderInput $input
|
|
*/
|
|
#[\Override]
|
|
public function __invoke(ActionInput $input): ConfirmPlacedOrderOutput
|
|
{
|
|
Assert::isInstanceOf($input, ConfirmPlacedOrderInput::class);
|
|
|
|
try {
|
|
$this->orderTunnelService->confirmPlacedOrder($input->orderId);
|
|
} catch (\Throwable $e) {
|
|
report($e);
|
|
|
|
return ConfirmPlacedOrderOutput::FAILED;
|
|
}
|
|
|
|
return ConfirmPlacedOrderOutput::CONFIRMED;
|
|
}
|
|
}
|