| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- 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();
- }
- }
|