<?php
namespace App\Controller\API;
use App\Controller\BaseController;
use App\Entity\Log\LogInteraction;
use App\Services\API\CarpetaCiudadanaService;
use App\Utils\APIResponse;
use App\Utils\CommonFunctions;
use Exception;
use OpenApi\Annotations as OA;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
/**
* @Route("/CarpetaCiudadana")
*/
class CarpetaCiudadanaController extends BaseController
{
/**
* @Route("/validaNivel", name="valida-nivel", methods={"POST"})
* @param Request $request
* @param CarpetaCiudadanaService $CarpetaCiudadanaService
* @return Response
*
* @OA\Post (
* path="/api/v1/CarpetaCiudadana/validaNivel",
* summary="Valicacion del nivel de miba",
* @OA\RequestBody(
* @OA\MediaType(
* mediaType="application/json",
* @OA\Schema(
* @OA\Property(property="nivel", type="string"),
* )
* )
* ),
* @OA\Response(
* response=200,
* description="Response",
* @OA\MediaType(
* mediaType="application/json",
* @OA\Schema(
* @OA\Property(property="status", type="integer"),
* @OA\Property(property="errors", type="array", @OA\Items(type="string")),
* @OA\Property(property="content", type="object")
* )
* )
* )
* )
*/
public function validaNivel(Request $request, CarpetaCiudadanaService $CarpetaCiudadanaService)
{
$statusCode = APIResponse::$SUCCESS;
$status = APIResponse::$SUCCESS;
$errors = array();
$result = null;
try {
$data = CommonFunctions::getValidJson($request->getContent());
$result = $CarpetaCiudadanaService->validarNivel($data);
} catch (Exception $e) {
$statusCode = APIResponse::$INTERNAL_ERROR;
$status = APIResponse::$INTERNAL_ERROR;
$errors = array($e->getMessage());
$errorInfo = CommonFunctions::getErrorException($e);
$this->logInteractionService->addErrorLog(
LogInteraction::$LIST,
CommonFunctions::getClassMethod(__METHOD__),
$e->getMessage(),
$errorInfo
);
}
return $this->generateJsonResponse($result, $statusCode, $status, $errors);
}
/**
* @Route("/documentos", name="documentos", methods={"POST"})
* @param Request $request
* @param CarpetaCiudadanaService $CarpetaCiudadanaService
* @return Response
*
* @OA\Post (
* path="/api/v1/CarpetaCiudadana/documentos",
* summary="Obtener los documento asociados al ciudadano",
* @OA\RequestBody(
* @OA\MediaType(
* mediaType="application/json",
* @OA\Schema(
* @OA\Property(property="mibaId", type="string"),
* @OA\Property(property="orden", type="string"),
* @OA\Property(property="tipoOrden", type="string"),
* @OA\Property(property="page", type="integer"),
* )
* )
* ),
* @OA\Response(
* response=200,
* description="Response",
* @OA\MediaType(
* mediaType="application/json",
* @OA\Schema(
* @OA\Property(property="status", type="integer"),
* @OA\Property(property="errors", type="array", @OA\Items(type="string")),
* @OA\Property(property="content", type="object")
* )
* )
* )
* )
*/
public function getDocumentosAction(Request $request, CarpetaCiudadanaService $CarpetaCiudadanaService)
{
$statusCode = APIResponse::$SUCCESS;
$status = APIResponse::$SUCCESS;
$errors = array();
$result = null;
try {
$data = CommonFunctions::getValidJson($request->getContent());
$result = $CarpetaCiudadanaService->getDocumentos($data);
} catch (Exception $e) {
$statusCode = APIResponse::$INTERNAL_ERROR;
$status = APIResponse::$INTERNAL_ERROR;
$errors = array($e->getMessage());
$errorInfo = CommonFunctions::getErrorException($e);
$this->logInteractionService->addErrorLog(
LogInteraction::$LIST,
CommonFunctions::getClassMethod(__METHOD__),
$e->getMessage(),
$errorInfo
);
}
return $this->generateJsonResponse($result, $statusCode, $status, $errors);
}
/**
* @Route("/documentoDigital", name="documentoDigital", methods={"POST"})
* @param Request $request
* @param CarpetaCiudadanaService $CarpetaCiudadanaService
* @return Response
*
* @OA\Post (
* path="/api/v1/CarpetaCiudadana/documentoDigital",
* summary="Obtener los documento asociados al ciudadano",
* @OA\RequestBody(
* @OA\MediaType(
* mediaType="application/json",
* @OA\Schema(
* @OA\Property(property="url", type="string"),
* )
* )
* ),
* @OA\Response(
* response=200,
* description="Response",
* @OA\MediaType(
* mediaType="application/json",
* @OA\Schema(
* @OA\Property(property="status", type="integer"),
* @OA\Property(property="errors", type="array", @OA\Items(type="string")),
* @OA\Property(property="content", type="object")
* )
* )
* )
* )
*/
public function getDocumentoDigitalAction(Request $request, CarpetaCiudadanaService $CarpetaCiudadanaService)
{
$statusCode = APIResponse::$SUCCESS;
$status = APIResponse::$SUCCESS;
$errors = array();
$result = null;
try {
$data = CommonFunctions::getValidJson($request->getContent());
$result = $CarpetaCiudadanaService->getDocumentoDigital($data);
} catch (Exception $e) {
$statusCode = APIResponse::$INTERNAL_ERROR;
$status = APIResponse::$INTERNAL_ERROR;
$errors = array($e->getMessage());
$errorInfo = CommonFunctions::getErrorException($e);
$this->logInteractionService->addErrorLog(
LogInteraction::$LIST,
CommonFunctions::getClassMethod(__METHOD__),
$e->getMessage(),
$errorInfo
);
}
return $this->generateJsonResponse($result, $statusCode, $status, $errors);
}
}