| 1234567891011121314151617181920212223242526272829303132333435363738 |
- using Web.Api.Common;
- using Web.Api.Extensions;
- using MediatR;
- using System.Security.Claims;
- using Domain.Entities.Wallets.ValueObject;
- namespace Web.Api.Endpoints.Wallet;
- internal sealed class Transactions : IEndpoint
- {
- public void MapEndpoint(IEndpointRouteBuilder app)
- {
- app.MapGet("api/wallet/transactions", async (
- ClaimsPrincipal user,
- ISender sender,
- int page = 1,
- ushort perPage = 20,
- WalletTransactionType? type = null,
- CancellationToken ct = default
- ) => {
- var memberID = user.GetMemberID();
- if (memberID is null)
- {
- return ApiResponse.Fail(StatusCodes.Status401Unauthorized, "Invalid token");
- }
- var result = await sender.Send(
- new Application.Features.Api.Member.Wallet.GetMyTransactions.Query(memberID.Value, page, perPage, type),
- ct
- );
- return ApiResponse.Ok(result);
- })
- .WithTags("Wallet")
- .RequireAuthorization();
- }
- }
|