<?php

namespace App\Http\Controllers\Api\V1\Admin\Config;

use App\Models\OddsVersion;
use Illuminate\Http\Request;
use App\Support\AdminApiList;
use Illuminate\Http\JsonResponse;
use App\Http\Controllers\Controller;
use App\Support\AdminConfigPresenter;
use App\Services\Config\OddsStreamService;

/** GET /api/v1/admin/config/odds-versions */
final class OddsVersionIndexController extends Controller
{
    public function __invoke(Request $request, OddsStreamService $service): JsonResponse
    {
        $p = AdminApiList::readPaging($request);
        $status = trim((string) $request->query('status', ''));

        $paginator = $service->paginate($status === '' ? null : $status, $p['perPage'], $p['page']);

        return AdminApiList::json($paginator, fn (OddsVersion $v) => AdminConfigPresenter::oddsVersionSummary($v));
    }
}
