<?php

declare(strict_types=1);

namespace ApiModel\Route;

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

final class AuthRoutes
{
    public static function register(RouteCollectorProxy $g, AuthAction $authAction): void
    {
        $g->post('/auth/login', fn (ServerRequestInterface $request, ResponseInterface $response) => HttpRunner::runJson($request, $response, fn () => $authAction->login($request)));

        $g->post('/auth/refresh', fn (ServerRequestInterface $request, ResponseInterface $response) => HttpRunner::runJson($request, $response, fn () => $authAction->refresh($request)));

        $g->post('/auth/logout', fn (ServerRequestInterface $request, ResponseInterface $response) => HttpRunner::runJson($request, $response, fn () => $authAction->logout($request)));

        $g->post('/auth/forgot-password', fn (ServerRequestInterface $request, ResponseInterface $response) => HttpRunner::runJson($request, $response, fn () => $authAction->forgotPassword($request)));

        $g->post('/auth/reset-password', fn (ServerRequestInterface $request, ResponseInterface $response) => HttpRunner::runJson($request, $response, fn () => $authAction->resetPassword($request)));
    }
}
