<?php declare(strict_types=1);

namespace App\Http\Controllers\Private;

use App\Http\Resources\Private\Websockets\Setting;
use App\Services\Private\WebsocketService;
use Illuminate\Http\JsonResponse;

final class WebsocketsController extends Controller
{
    public function __construct(
        private readonly WebsocketService $websocketService,
    ) { }

    public function settings(): JsonResponse
    {
        $result = $this->websocketService->settings();
        if (!$result->isSuccess()) {
            return response()->json($result->getData())->setStatusCode($result->getCode());
        }

        return response()->json(new Setting($result));
    }
}
