using Web.Api.Common;
using MediatR;

namespace Web.Api.Endpoints.Donation;

/// <summary>크루 방송 종료</summary>
internal sealed class CrewSessionEnd : IEndpoint
{
    public void MapEndpoint(IEndpointRouteBuilder app)
    {
        /// 정산 처리(수수료 차감 → 지갑 입금) + Ended 전환 + 크루원에게 쪽지 발송
        app.MapPost("api/crew/session/end", async (
            Application.Features.Api.Crew.EndSession.Command body,
            ISender sender,
            CancellationToken ct
        ) => {
            await sender.Send(body, ct);
            return ApiResponse.Ok();
        })
        .WithTags("Crew")
        .RequireAuthorization();
    }
}