47 lines
1.3 KiB
PHP
47 lines
1.3 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
namespace App\Queries\Orders;
|
||
|
|
|
||
|
|
use App\Contracts\Query;
|
||
|
|
use App\Contracts\QueryInput;
|
||
|
|
use App\Dto\ShopDto;
|
||
|
|
use App\Services\MapUrlService;
|
||
|
|
use Domain\Enums\OrderTunnelStep;
|
||
|
|
use Domain\Services\OrderTunnelService;
|
||
|
|
use Webmozart\Assert\Assert;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @implements \App\Contracts\Query<\App\Queries\Orders\GetPickTimeSlotQueryInput, \App\Queries\Orders\GetPickTimeSlotQueryOutput>
|
||
|
|
*/
|
||
|
|
final readonly class GetPickTimeSlotQuery implements Query
|
||
|
|
{
|
||
|
|
public function __construct(
|
||
|
|
private OrderTunnelService $orderTunnelService,
|
||
|
|
private MapUrlService $mapUrlService,
|
||
|
|
) {
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @param \App\Queries\Orders\GetPickTimeSlotQueryInput $input
|
||
|
|
*/
|
||
|
|
#[\Override]
|
||
|
|
public function __invoke(QueryInput $input): GetPickTimeSlotQueryOutput
|
||
|
|
{
|
||
|
|
Assert::isInstanceOf($input, GetPickTimeSlotQueryInput::class);
|
||
|
|
|
||
|
|
$shop = $this->orderTunnelService->getShopForCustomer($input->shopperId);
|
||
|
|
$timeSlots = $this->orderTunnelService->getAvailableTimeSlots($shop);
|
||
|
|
$shopDto = ShopDto::fromDomain($shop);
|
||
|
|
$mapUrl = $this->mapUrlService->generateUrl($shopDto);
|
||
|
|
|
||
|
|
return new GetPickTimeSlotQueryOutput(
|
||
|
|
step: OrderTunnelStep::BOOKING,
|
||
|
|
shop: $shopDto,
|
||
|
|
timeSlots: $timeSlots,
|
||
|
|
mapUrl: $mapUrl,
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|