using Web.Api.Common;
using MediatR;

namespace Web.Api.Endpoints.Donation;

/// <summary>크루 방송 시작</summary>
internal sealed class CrewSessionStart : IEndpoint
{
    public void MapEndpoint(IEndpointRouteBuilder app)
    {
        /// 전원 동의(Ready) 상태에서만 시작. Active 전환 후 DonationHub 브로드캐스트
        app.MapPost("api/crew/session/start", async (
            Application.Features.Api.Crew.StartSession.Command body,
            ISender sender,
            CancellationToken ct
        ) => {
            var data = await sender.Send(body, ct);
            return ApiResponse.Ok(data);
        })
        .WithTags("Crew")
        .RequireAuthorization();
    }
}