<?php
declare(strict_types=1);
namespace Slivki\Controller\MobileApi\V2\MeOnMap;
use Slivki\Message\Query\MeOnMap\GetGeoLocationsQuery;
use Slivki\MessageHandler\Query\MeOnMap\GetGeoLocationHandler;
use Slivki\Request\MeOnMap\GetGeoLocationsRequest;
use OpenApi\Annotations as OA;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Annotation\Route;
final class GetGeoLocationsAction extends AbstractController
{
private GetGeoLocationHandler $geoLocationHandler;
public function __construct(GetGeoLocationHandler $geoLocationHandler)
{
$this->geoLocationHandler = $geoLocationHandler;
}
/**
* @Route("/mobile/api/v2/me-on-map/geo-locations", methods={"GET"}, name="mobile_api_v2_me_on_map_geo_locations_get")
* @OA\Tag(name="Me on map")
* @OA\Response(
* response=200,
* description="Список геолокаций",
* content={
* @OA\MediaType(
* mediaType="application/json",
* @OA\Schema(
* @OA\Property(property="id", type="integer", description="ID геологации"),
* @OA\Property(property="offerId", type="integer", description="ID акции"),
* @OA\Property(property="offerWithoutCodes", type="boolean", description="Акция без промокодов"),
* @OA\Property(property="latitude", type="float", description="Широта"),
* @OA\Property(property="longitude", type="float", description="Долгота"),
* @OA\Property(property="mapPinColor", type="string", description="Цвет иконки"),
* @OA\Property(property="mapPinImageUrl", type="string", description="Картинка иконки"),
* @OA\Property(property="offerLogoImageUrl", type="string", description="Картинка логотипа акции"),
* @OA\Property(property="mapPrice", type="float", description="Цена на карте"),
* @OA\Property(property="mapRating", type="integer", description="Рейтинг на карте"),
* @OA\Property(property="address", type="string", description="Адрес"),
* @OA\Property(property="phones", type="array", description="Телефоны",
* @OA\Items(
* @OA\Property(property="phoneNumber", type="string", description="Номер"),
* @OA\Property(property="label", type="string", description="Пометка"),
* ),
* ),
* type="object",
* ),
* ),
* }
* ),
* @OA\Parameter(
* name="searchQuery",
* in="query",
* description="Поисковый запрос",
* required=false,
* @OA\Schema(type="string"),
* ),
* @OA\Parameter(
* name="categoryIds[]",
* in="query",
* description="массив ID категорий",
* required=false,
* @OA\Schema(type="array", @OA\Items(type="integer")),
* )
*/
public function __invoke(GetGeoLocationsRequest $request): JsonResponse
{
return new JsonResponse(
$this->geoLocationHandler->__invoke(new GetGeoLocationsQuery(
$request->getSearchQuery(),
$request->getCategoryIds()
)),
);
}
}