| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- using MediatR;
- using Web.Api.Common;
- using Web.Api.Extensions;
- namespace Web.Api.Endpoints.V1.Channels;
- internal sealed class Get : IEndpoint
- {
- public void MapEndpoint(IEndpointRouteBuilder app)
- {
- app.MapGet("v1/channels/{code}", async (
- string code,
- ISender sender,
- CancellationToken ct
- ) => {
- var query = new Application.Features.Api.V1.Channels.GetByCode.Query(code);
- var result = await sender.Send(query, ct);
- return result.Match(
- data => ApiResponse.Ok(data),
- CustomResults.Problem
- );
- })
- .WithTags("채널")
- .WithGroupName("public")
- .WithName("GetChannelByCode")
- .WithSummary("채널 후원 코드 확인")
- .WithDescription("""
- 채널 후원 코드의 존재·활성 여부를 확인합니다.
- 게임 내에서 유저가 입력한 코드를 **결제 보고 전에 사전 검증**하는 용도입니다.
- ### 필수 scope
- - `read:channels`
- ### 경로 변수
- - `code` — 채널 후원 코드 (4~7자 영문+숫자, 대소문자 무관)
- ### 응답 필드
- - `channelSID` / `channelName` — 채널 식별 정보
- - `active` — `false` 면 해당 코드로 결제 등록이 거부됩니다
- ### 에러
- - `404` — 코드 없음
- """)
- .Produces<ApiResponse>(StatusCodes.Status200OK)
- .ProducesProblem(StatusCodes.Status400BadRequest)
- .ProducesProblem(StatusCodes.Status401Unauthorized)
- .ProducesProblem(StatusCodes.Status403Forbidden)
- .ProducesProblem(StatusCodes.Status404NotFound)
- .RequireAuthorization(policy => policy
- .AddAuthenticationSchemes("ApiKey", "OAuth2Bearer")
- .RequireAuthenticatedUser())
- .RequireScope("read:channels");
- }
- }
|