<?php

namespace App\Http\Controllers\Api\V1\Jackpot;

use App\Support\ApiResponse;
use Illuminate\Http\Request;
use Illuminate\Http\JsonResponse;
use App\Http\Controllers\Controller;
use App\Services\LotterySettings;
use App\Services\Jackpot\JackpotSummaryService;

/**
 * `GET /api/v1/jackpot/summary` — 当前奖池水位（公开；玩家端开奖区展示）。
 */
final class JackpotSummaryController extends Controller
{
    public function __construct(
        private readonly JackpotSummaryService $summary,
    ) {}

    public function __invoke(Request $request): JsonResponse
    {
        $currencyCode = strtoupper(trim((string) $request->query(
            'currency_code',
            LotterySettings::defaultCurrency(),
        )));

        return ApiResponse::success($this->summary->summary($currencyCode));
    }
}
