using MediatR; using Web.Api.Common; namespace Web.Api.Endpoints.Crypto; internal sealed class CryptoCandles : IEndpoint { public void MapEndpoint(IEndpointRouteBuilder app) { app.MapGet("api/crypto/{symbol}/candles/seconds", async ( string symbol, int? count, ISender sender, CancellationToken ct ) => { return ApiResponse.Ok( await sender.Send(new Application.Features.Api.Crypto.Candle.GetSeconds.Query(symbol, count ?? 200), ct) ); }) .WithTags("Crypto") .AllowAnonymous(); app.MapGet("api/crypto/{symbol}/candles/minutes/{unit:int}", async ( string symbol, int unit, int? count, ISender sender, CancellationToken ct ) => { return ApiResponse.Ok( await sender.Send(new Application.Features.Api.Crypto.Candle.GetMinutes.Query(symbol, unit, count ?? 200), ct) ); }) .WithTags("Crypto") .AllowAnonymous(); app.MapGet("api/crypto/{symbol}/candles/days", async ( string symbol, int? count, ISender sender, CancellationToken ct ) => { return ApiResponse.Ok( await sender.Send(new Application.Features.Api.Crypto.Candle.GetDays.Query(symbol, count ?? 200), ct) ); }) .WithTags("Crypto") .AllowAnonymous(); app.MapGet("api/crypto/{symbol}/candles/weeks", async ( string symbol, int? count, ISender sender, CancellationToken ct ) => { return ApiResponse.Ok( await sender.Send(new Application.Features.Api.Crypto.Candle.GetWeeks.Query(symbol, count ?? 200), ct) ); }) .WithTags("Crypto") .AllowAnonymous(); app.MapGet("api/crypto/{symbol}/candles/months", async ( string symbol, int? count, ISender sender, CancellationToken ct ) => { return ApiResponse.Ok( await sender.Send(new Application.Features.Api.Crypto.Candle.GetMonths.Query(symbol, count ?? 200), ct) ); }) .WithTags("Crypto") .AllowAnonymous(); app.MapGet("api/crypto/{symbol}/candles/years", async ( string symbol, int? count, ISender sender, CancellationToken ct ) => { return ApiResponse.Ok( await sender.Send(new Application.Features.Api.Crypto.Candle.GetYears.Query(symbol, count ?? 200), ct) ); }) .WithTags("Crypto") .AllowAnonymous(); app.MapGet("api/crypto/{symbol}/candles/live/{interval}", async ( string symbol, string interval, ISender sender, CancellationToken ct ) => { return ApiResponse.Ok( await sender.Send(new Application.Features.Api.Crypto.Candle.GetLive.Query(symbol, interval), ct) ); }) .WithTags("Crypto") .AllowAnonymous(); } }