using System.Security.Claims; using Domain.Entities.Store.ValueObject; using Application.Abstractions.Messaging; using Web.Api.Common; using Web.Api.Extensions; namespace Web.Api.Endpoints.Store; /// 상점 — 본인 주문에 대한 환불(취소/반품/교환/환불) 신청. internal sealed class OrdersRequestRefund : IEndpoint { public sealed record Body(RefundType Type, RefundReasonType ReasonType, string? ReasonMemo); public void MapEndpoint(IEndpointRouteBuilder app) { app.MapPost("api/store/orders/{id:int}/refunds", async ( int id, Body body, ClaimsPrincipal user, ISender sender, CancellationToken ct ) => { var memberID = user.GetRequiredMemberID(); var result = await sender.Send(new Application.Features.Api.Store.Orders.RequestRefund.Command( memberID, id, body.Type, body.ReasonType, body.ReasonMemo ), ct); return result.Match( data => ApiResponse.Ok(data), CustomResults.Problem ); }) .WithTags("Store") .RequireAuthorization(); } }