using Microsoft.Extensions.Logging; using DD.Persistence.Client.Clients.Base; using DD.Persistence.Client.Clients.Interfaces; using DD.Persistence.Client.Clients.Interfaces.Refit; using DD.Persistence.Models; namespace DD.Persistence.Client.Clients; public class TimeSeriesClient : BaseClient, ITimeSeriesClient where TDto : class, ITimeSeriesAbstractDto { private readonly IRefitTimeSeriesClient timeSeriesClient; public TimeSeriesClient(IRefitClientFactory> refitTechMessagesClientFactory, ILogger> logger) : base(logger) { this.timeSeriesClient = refitTechMessagesClientFactory.Create(); } public async Task AddRange(IEnumerable dtos, CancellationToken token) { var result = await ExecutePostResponse( async () => await timeSeriesClient.AddRange(dtos, token), token); return result; } public async Task> Get(DateTimeOffset dateBegin, DateTimeOffset dateEnd, CancellationToken token) { var result = await ExecuteGetResponse( async () => await timeSeriesClient.Get(dateBegin, dateEnd, token), token); return result!; } public async Task> GetResampledData(DateTimeOffset dateBegin, double intervalSec = 600d, int approxPointsCount = 1024, CancellationToken token = default) { var result = await ExecuteGetResponse( async () => await timeSeriesClient.GetResampledData(dateBegin, intervalSec, approxPointsCount, token), token); return result!; } public async Task GetDatesRange(CancellationToken token) { var result = await ExecuteGetResponse( async () => await timeSeriesClient.GetDatesRange(token), token); return result; } public void Dispose() { timeSeriesClient.Dispose(); GC.SuppressFinalize(this); } }