<?php

declare(strict_types=1);

namespace ApiModel\Route;

use ApiModel\Action\CertificadoAction;
use ApiModel\Shared\Support\HttpRunner;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Slim\Routing\RouteCollectorProxy;

final class CertificadoRoutes
{
    public static function register(RouteCollectorProxy $g, CertificadoAction $action, string $uuid): void
    {
        $g->get('/certificados', fn (ServerRequestInterface $request, ResponseInterface $response) => HttpRunner::runJson($request, $response, fn () => $action->listar($request)));
        $g->get('/certificados/por-codigo/{codigo}/consultar', fn (ServerRequestInterface $request, ResponseInterface $response, array $args) => HttpRunner::runJson($request, $response, fn () => $action->consultarDetallePorCodigo($request, $args['codigo'])));
        $g->get("/certificados/{id:$uuid}", fn (ServerRequestInterface $request, ResponseInterface $response, array $args) => HttpRunner::runJson($request, $response, fn () => $action->obtener($request, $args['id'])));
        $g->get("/certificados/{id:$uuid}/consultar", fn (ServerRequestInterface $request, ResponseInterface $response, array $args) => HttpRunner::runJson($request, $response, fn () => $action->consultarDetalle($request, $args['id'])));
        $g->post('/certificados', fn (ServerRequestInterface $request, ResponseInterface $response) => HttpRunner::runJson($request, $response, fn () => $action->crear($request)));
        $g->post("/certificados/{id:$uuid}/anular", fn (ServerRequestInterface $request, ResponseInterface $response, array $args) => HttpRunner::runJson($request, $response, fn () => $action->anular($request, $args['id'])));
    }
}
