<?php

declare(strict_types=1);

namespace ApiModel\Route;

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

final class PagoFerreteriaRoutes
{
    public static function register(RouteCollectorProxy $g, PagoFerreteriaAction $action, string $uuid): void
    {
        $g->get('/pagos-ferreterias', fn (ServerRequestInterface $request, ResponseInterface $response) => HttpRunner::runJson($request, $response, fn () => $action->listar($request)));
        $g->post('/pagos-ferreterias', fn (ServerRequestInterface $request, ResponseInterface $response) => HttpRunner::runJson($request, $response, fn () => $action->crear($request)));
        $g->delete("/pagos-ferreterias/{id:$uuid}", fn (ServerRequestInterface $request, ResponseInterface $response, array $args) => HttpRunner::runJson($request, $response, fn () => $action->eliminar($request, $args['id'])));
    }
}
