<?php

declare(strict_types=1);

namespace ApiModel\Route;

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

final class UserRoutes
{
    public static function register(RouteCollectorProxy $g, UserAction $userAction): void
    {
        $g->get('/users/me', fn (ServerRequestInterface $request, ResponseInterface $response) => HttpRunner::runJson($request, $response, fn () => $userAction->me($request)));

        $g->patch('/users/me/language', fn (ServerRequestInterface $request, ResponseInterface $response) => HttpRunner::runJson($request, $response, fn () => $userAction->updateLanguage($request)));

        $g->patch('/users/me/photo', fn (ServerRequestInterface $request, ResponseInterface $response) => HttpRunner::runJson($request, $response, fn () => $userAction->updatePhoto($request)));
    }
}
