using FastEndpoints;
using SpaceGame.Api.Universe.Simulation;

namespace SpaceGame.Api.Universe.Api;

public sealed class UpdateBalanceHandler(IBalanceService balanceService) : Endpoint<BalanceOptions>
{
    public override void Configure()
    {
        Put("/api/balance");
        Policies(AuthPolicyNames.GmAccess);
    }

    public override Task HandleAsync(BalanceOptions req, CancellationToken cancellationToken)
    {
        var applied = balanceService.Update(req);
        return SendOkAsync(applied, cancellationToken);
    }
}
