src/Controller/MobileApi/V2/GiftCertificate/GetGiftCertificateCategoriesAction.php line 13

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Slivki\Controller\MobileApi\V2\GiftCertificate;
  4. use Slivki\Message\Query\GiftCertificate\GetGiftCertificateCategoriesQuery;
  5. use Slivki\Messenger\Query\QueryBusInterface;
  6. use OpenApi\Annotations as OA;
  7. use Symfony\Component\HttpFoundation\JsonResponse;
  8. use Symfony\Component\Routing\Annotation\Route;
  9. final class GetGiftCertificateCategoriesAction
  10. {
  11.     private QueryBusInterface $queryBus;
  12.     public function __construct(QueryBusInterface $queryBus)
  13.     {
  14.         $this->queryBus $queryBus;
  15.     }
  16.     /**
  17.      * @Route("/mobile/api/v2/offer/{offerId}/gift-certificate/categories", methods={"GET"}, name="mobile_api_v2_offer_gift_certificate_categories_get")
  18.      * @OA\Tag(name="GiftCertificate")
  19.      * @OA\Response(
  20.      *     response=200,
  21.      *     description="Cписок категорий",
  22.      *     @OA\Schema(
  23.      *          @OA\Property(property="id", type="integer", description="ID категории"),
  24.      *          @OA\Property(property="count", type="integer", description="Количество акций в категории"),
  25.      *          @OA\Property(property="name", type="string", description="Название категории"),
  26.      *     )
  27.      * )
  28.      */
  29.     public function __invoke(int $offerId): JsonResponse
  30.     {
  31.         return new JsonResponse(
  32.             $this->queryBus->handle(
  33.                 new GetGiftCertificateCategoriesQuery($offerId),
  34.             ),
  35.         );
  36.     }
  37. }