src/Controller/API/GedoController.php line 42

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\GedoService;
  6. use App\Utils\APIResponse;
  7. use App\Utils\CommonFunctions;
  8. use Exception;
  9. use Symfony\Component\HttpFoundation\Request;
  10. use Symfony\Component\HttpFoundation\Response;
  11. use Symfony\Component\Routing\Annotation\Route;
  12. use OpenApi\Annotations as OA;
  13. /**
  14.  * @Route("/Gedo_consulta_documento")
  15.  */
  16. class GedoController extends BaseController
  17. {
  18.     /**
  19.      * @Route("", name="post_gedo_consulta_documento", methods={"POST"})
  20.      * @return Response
  21.      *
  22.      * @OA\Post(
  23.      *     path="/api/v1/Gedo_consulta_documento",
  24.      *     summary="Obtener documentos",
  25.      *     @OA\Response(
  26.      *         response=200,
  27.      *         description="Response",
  28.      *         @OA\MediaType(
  29.      *             mediaType="application/json",
  30.      *             @OA\Schema(
  31.      *                 @OA\Property(property="status", type="integer"),
  32.      *                 @OA\Property(property="errors", type="array", @OA\Items(type="string")),
  33.      *                 @OA\Property(property="content", type="object")
  34.      *            )
  35.      *        )
  36.      *    )
  37.      * )
  38.      */
  39.     public function getDocumentos(Request $request,  GedoService $gedoService)
  40.     {
  41.         $statusCode APIResponse::$SUCCESS;
  42.         $status APIResponse::$SUCCESS;
  43.         $errors = array();
  44.         $result null;
  45.         try {
  46.             $data CommonFunctions::getValidJson($request->getContent());
  47.             $result $gedoService->getDocumentos($data);
  48.         }catch (Exception $e){
  49.             $statusCode APIResponse::$INTERNAL_ERROR;
  50.             $status APIResponse::$INTERNAL_ERROR;
  51.             $errors = array($e->getMessage());
  52.             $errorInfo CommonFunctions::getErrorException($e);
  53.             $this->logInteractionService->addErrorLog(
  54.                 LogInteraction::$LIST,
  55.                 CommonFunctions::getClassMethod(__METHOD__),
  56.                 $e->getMessage(),
  57.                 $errorInfo
  58.             );
  59.         }
  60.         return $this->generateJsonResponse($result$statusCode$status$errors);
  61.     }
  62. }