src/Controller/API/NotificacionesController.php line 50

Open in your IDE?
  1. <?php
  2. namespace App\Controller\API;
  3. use App\Controller\BaseController;
  4. use App\Entity\Log\LogInteraction;
  5. use App\Services\API\NotificacionesService;
  6. use App\Utils\APIResponse;
  7. use App\Utils\CommonFunctions;
  8. use Exception;
  9. use OpenApi\Annotations as OA;
  10. use Symfony\Component\HttpFoundation\Request;
  11. use Symfony\Component\HttpFoundation\Response;
  12. use Symfony\Component\Routing\Annotation\Route;
  13. /**
  14.  * @Route("/notificaciones")
  15.  */
  16. class NotificacionesController extends BaseController
  17. {
  18.     /**
  19.      * @Route("", name="get_notificaciones", methods={"POST"})
  20.      * @param Request $request
  21.      * @param NotificacionesService $notificacionesService
  22.      * @return Response
  23.      *
  24.      * @OA\Post(
  25.      *     path="/api/v1/notificaciones",
  26.      *     summary="Obtener las notificaciones del usuario",
  27.      *     @OA\Parameter(
  28.      *         name="page",
  29.      *         in="query",
  30.      *         required=false,
  31.      *         @OA\Schema(type="integer")
  32.      *     ),
  33.      *     @OA\Response(
  34.      *         response=200,
  35.      *         description="Response",
  36.      *         @OA\MediaType(
  37.      *             mediaType="application/json",
  38.      *             @OA\Schema(
  39.      *                 @OA\Property(property="status", type="integer"),
  40.      *                 @OA\Property(property="errors", type="array", @OA\Items(type="string")),
  41.      *                 @OA\Property(property="content", type="object")
  42.      *            )
  43.      *        )
  44.      *    )
  45.      * )
  46.      */
  47.     public function notificacionesAction(Request $requestNotificacionesService $notificacionesService)
  48.     {
  49.         $statusCode APIResponse::$SUCCESS;
  50.         $status APIResponse::$SUCCESS;
  51.         $errors = array();
  52.         $result null;
  53.         try {
  54.             $data CommonFunctions::getValidJson($request->getContent());
  55.             $result $notificacionesService->getNotificaciones($data);
  56.         } catch (Exception $e) {
  57.             $statusCode APIResponse::$INTERNAL_ERROR;
  58.             $status APIResponse::$INTERNAL_ERROR;
  59.             $errors = array($e->getMessage());
  60.             $errorInfo CommonFunctions::getErrorException($e);
  61.             $this->logInteractionService->addErrorLog(
  62.                 LogInteraction::$LIST,
  63.                 CommonFunctions::getClassMethod(__METHOD__),
  64.                 $e->getMessage(),
  65.                 $errorInfo
  66.             );
  67.         }
  68.         return $this->generateJsonResponse($result$statusCode$status$errors);
  69.     }
  70.     /**
  71.      * @Route("/marcarLeida", name="marcar_leida", methods={"POST"})
  72.      * @param Request $request
  73.      * @param NotificacionesService $notificacionesService
  74.      * @return Response
  75.      *
  76.      * @OA\Post(
  77.      *     path="/api/v1/notificaciones/marcarLeida",
  78.      *     summary="Marcar una notificacion del usuario como leida",
  79.      *     @OA\Response(
  80.      *         response=200,
  81.      *         description="Response",
  82.      *         @OA\MediaType(
  83.      *             mediaType="application/json",
  84.      *             @OA\Schema(
  85.      *                 @OA\Property(property="status", type="integer"),
  86.      *                 @OA\Property(property="errors", type="array", @OA\Items(type="string")),
  87.      *                 @OA\Property(property="content", type="object")
  88.      *            )
  89.      *        )
  90.      *    )
  91.      * )
  92.      */
  93.     public function marcarLeida(Request $requestNotificacionesService $notificacionesService)
  94.     {
  95.         $statusCode APIResponse::$SUCCESS;
  96.         $status APIResponse::$SUCCESS;
  97.         $errors = array();
  98.         $result null;
  99.         try {
  100.             $data CommonFunctions::getValidJson($request->getContent());
  101.             $result $notificacionesService->marcarLeida($data);
  102.         } catch (Exception $e) {
  103.             $statusCode APIResponse::$INTERNAL_ERROR;
  104.             $status APIResponse::$INTERNAL_ERROR;
  105.             $errors = array($e->getMessage());
  106.             $errorInfo CommonFunctions::getErrorException($e);
  107.             $this->logInteractionService->addErrorLog(
  108.                 LogInteraction::$LIST,
  109.                 CommonFunctions::getClassMethod(__METHOD__),
  110.                 $e->getMessage(),
  111.                 $errorInfo
  112.             );
  113.         }
  114.         return $this->generateJsonResponse($result$statusCode$status$errors);
  115.     }
  116. }