<?php

namespace App\Http\Controllers;

use App\Core\Request;
use App\Core\Response;
use App\Domain\Repositories\UserRepositoryInterface;
use App\Http\Responses\ApiResponse;

class UserController
{
    public function __construct(private UserRepositoryInterface $users)
    {
    }

    public function me(Request $request): Response
    {
        $user = $this->users->findById((int)$request->attribute('user_id'));
        return ApiResponse::success(['user' => $user?->publicArray()]);
    }

    public function roles(Request $request): Response
    {
        return Response::json(['roles' => $this->users->roles(), 'success' => true]);
    }

    public function statuses(Request $request): Response
    {
        return Response::json(['statuses' => $this->users->statuses(), 'success' => true]);
    }
}
