Transactions.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using Web.Api.Common;
  2. using Web.Api.Extensions;
  3. using MediatR;
  4. using System.Security.Claims;
  5. using Domain.Entities.Wallets.ValueObject;
  6. namespace Web.Api.Endpoints.Wallet;
  7. internal sealed class Transactions : IEndpoint
  8. {
  9. public void MapEndpoint(IEndpointRouteBuilder app)
  10. {
  11. app.MapGet("api/wallet/transactions", async (
  12. ClaimsPrincipal user,
  13. ISender sender,
  14. int page = 1,
  15. ushort perPage = 20,
  16. WalletTransactionType? type = null,
  17. CancellationToken ct = default
  18. ) => {
  19. var memberID = user.GetMemberID();
  20. if (memberID is null)
  21. {
  22. return ApiResponse.Fail(StatusCodes.Status401Unauthorized, "Invalid token");
  23. }
  24. var result = await sender.Send(
  25. new Application.Features.Api.Member.Wallet.GetMyTransactions.Query(memberID.Value, page, perPage, type),
  26. ct
  27. );
  28. return ApiResponse.Ok(result);
  29. })
  30. .WithTags("Wallet")
  31. .RequireAuthorization();
  32. }
  33. }