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 WitsDataClient : BaseClient, IWitsDataClient { private readonly IRefitWitsDataClient refitWitsDataClient; public WitsDataClient(IRefitClientFactory refitWitsDataClientFactory, ILogger logger) : base(logger) { this.refitWitsDataClient = refitWitsDataClientFactory.Create(); } public async Task AddRange(IEnumerable dtos, CancellationToken token) { var result = await ExecutePostResponse( async () => await refitWitsDataClient.AddRange(dtos, token), token); return result; } public async Task GetDatesRangeAsync(Guid discriminatorId, CancellationToken token) { var result = await ExecuteGetResponse( async () => await refitWitsDataClient.GetDatesRangeAsync(discriminatorId, token), token); return result!; } public async Task> GetPart(Guid discriminatorId, DateTimeOffset dateBegin, int take = 86400, CancellationToken token = default) { var result = await ExecuteGetResponse( async () => await refitWitsDataClient.GetPart(discriminatorId, dateBegin, take, token), token); return result!; } public async Task> GetValuesForGraph(Guid discriminatorId, DateTimeOffset dateFrom, DateTimeOffset dateTo, int approxPointsCount, CancellationToken token) { var result = await ExecuteGetResponse( async () => await refitWitsDataClient.GetValuesForGraph(discriminatorId, dateFrom, dateTo, approxPointsCount, token), token); return result!; } public void Dispose() { refitWitsDataClient.Dispose(); GC.SuppressFinalize(this); } }