using System.Security.Claims;
using MediatR;
using Web.Api.Common;
using Web.Api.Extensions;

namespace Web.Api.Endpoints.Studio.Settings;

/// <summary>맞춤설정 — YouTube 채널 정보 조회</summary>
internal sealed class GetSettings : IEndpoint
{
    public void MapEndpoint(IEndpointRouteBuilder app)
    {
        app.MapGet("api/studio/settings", async (
            ClaimsPrincipal user,
            ISender sender,
            CancellationToken ct
        ) => {
            var memberID = user.GetRequiredMemberID();
            var result = await sender.Send(new Application.Features.Api.Studio.GetSettings.Query(memberID), ct);

            return result.Match(
                data => ApiResponse.Ok(data),
                CustomResults.Problem
            );
        })
        .WithTags("Studio")
        .RequireAuthorization();
    }
}