<?php
declare(strict_types=1);
namespace Slivki\Controller\MobileApi\V2\Beauty\Appointment;
use OpenApi\Annotations as OA;
use Nelmio\ApiDocBundle\Annotation\Model;
use DateTimeImmutable;
use Slivki\BusinessFeature\Yclients\Message\Query\SearchAvailableAppointmentWithOfferInfoQuery;
use Slivki\BusinessFeature\Yclients\Request\SearchAvailableAppointmentRequest;
use Slivki\BusinessFeature\Yclients\Response\OfferWithInfoAppointmentsResponse;
use Slivki\Messenger\Query\QueryBusInterface;
use Slivki\ValueObject\Coordinate;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Annotation\Route;
final class SearchAvailableAppointmentWithOfferInfoAction
{
private QueryBusInterface $queryBus;
public function __construct(QueryBusInterface $queryBus)
{
$this->queryBus = $queryBus;
}
/**
* @Route("/mobile/api/v2/beauty/appointment/search_with_offer", methods={"GET"}, name="mobile_api_v2_beauty_appointment_search_with_offer_get"),
* @OA\Tag(name="Beauty"),
* @OA\Response(
* response=200,
* description="Список доступных дат и времени для записи с информацией окции",
* @OA\JsonContent(
* type="array",
* description="Доступные даты и время для записи",
* @OA\Items(ref=@Model(type=OfferWithInfoAppointmentsResponse::class)),
* ),
* ),
*
* @OA\Parameter(
* name="categoryId",
* in="query",
* description="The ID of the category",
* @OA\Schema(type="integer", example=12345, nullable=false),
* ),
* @OA\Parameter(
* name="date",
* in="query",
* description="Дата",
* required=true,
* ),
* @OA\Parameter(
* name="rangeTime",
* in="query",
* description="Диапазон времени",
* required=true,
* @OA\Schema(type="string", example="10:00-18:00", nullable=false),
* ),
* @OA\Parameter(
* name="latitude",
* in="query",
* description="Широта",
* @OA\Schema(type="number", format="float", example=55.7558, nullable=true),
* required=false,
* ),
* @OA\Parameter(
* name="longitude",
* in="query",
* description="Долгота",
* @OA\Schema(type="number", format="float", example=37.6173, nullable=true),
* required=false,
* ),
* @OA\Parameter(
* name="sortBy",
* in="query",
* description="Сортировка",
* @OA\Schema(type="string", example="rating", nullable=true),
* required=false,
* ),
*/
public function __invoke(SearchAvailableAppointmentRequest $request): JsonResponse
{
return new JsonResponse(
$this->queryBus->handle(
new SearchAvailableAppointmentWithOfferInfoQuery(
$request->getCategoryId(),
new DateTimeImmutable($request->getDate()),
$request->getRangeTime(),
$request->getLatitude() === null || $request->getLongitude() === null
? null
: new Coordinate($request->getLatitude(), $request->getLongitude()),
$request->getSortBy(),
),
),
);
}
}