<?php

declare(strict_types=1);

namespace ApiModel\Route;

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

final class NotificationRoutes
{
    public static function register(RouteCollectorProxy $g, NotificationAction $notificationAction, string $uuid): void
    {
        $g->get('/notifications', fn (ServerRequestInterface $request, ResponseInterface $response) => HttpRunner::runJson($request, $response, fn () => $notificationAction->list($request)));

        $g->patch('/notifications/read-all', fn (ServerRequestInterface $request, ResponseInterface $response) => HttpRunner::runJson($request, $response, fn () => $notificationAction->markAllRead($request)));

        $g->patch("/notifications/{id:$uuid}/read", fn (ServerRequestInterface $request, ResponseInterface $response, array $args) => HttpRunner::runJson($request, $response, fn () => $notificationAction->markOneRead($request, $args['id'])));
    }
}
