using Web.Api.Common;
using MediatR;

namespace Web.Api.Endpoints.Widget;

/// <summary>후원 목표 진행 상태 조회 (OBS 브라우저 소스용, 인증 불필요)</summary>
internal sealed class GoalProgress : IEndpoint
{
    public void MapEndpoint(IEndpointRouteBuilder app)
    {
        app.MapGet("api/widget/goal/progress/{channelID}/{goalConfigID}", async (
            int channelID,
            int goalConfigID,
            ISender sender,
            CancellationToken ct
        ) => {
            var data = await sender.Send(new Application.Features.Api.DonationGoal.GetProgress.Query(channelID, goalConfigID), ct);
            return ApiResponse.Ok(data);
        })
        .WithTags("Widget")
        .AllowAnonymous();
    }
}