using Web.Api.Common;
using MediatR;

namespace Web.Api.Endpoints.Widget;

/// <summary>후원 알림 위젯 설정 조회 (OBS 브라우저 소스용, 인증 불필요)</summary>
internal sealed class AlertConfig : IEndpoint
{
    public void MapEndpoint(IEndpointRouteBuilder app)
    {
        app.MapGet("api/widget/alert/config/{widgetToken}", async (
            string widgetToken,
            ISender sender,
            CancellationToken ct
        ) => {
            var data = await sender.Send(new Application.Features.Api.DonationAlert.GetConfigByToken.Query(widgetToken), ct);
            return ApiResponse.Ok(data);
        })
        .WithTags("Widget")
        .AllowAnonymous();
    }
}