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 SetpointClient : BaseClient, ISetpointClient { private readonly IRefitSetpointClient refitSetpointClient; public SetpointClient(IRefitSetpointClient refitSetpointClient, ILogger logger) : base(logger) { this.refitSetpointClient = refitSetpointClient; } public async Task> GetCurrent(IEnumerable setpointKeys, CancellationToken token) { var result = await ExecuteGetResponse( async () => await refitSetpointClient.GetCurrent(setpointKeys, token), token); return result!; } public async Task> GetHistory(IEnumerable setpointKeys, DateTimeOffset historyMoment, CancellationToken token) { var result = await ExecuteGetResponse( async () => await refitSetpointClient.GetHistory(setpointKeys, historyMoment, token), token); return result!; } public async Task>> GetLog(IEnumerable setpointKeys, CancellationToken token) { var result = await ExecuteGetResponse( async () => await refitSetpointClient.GetLog(setpointKeys, token), token); return result!; } public async Task GetDatesRangeAsync(CancellationToken token) { var result = await ExecuteGetResponse( async () => await refitSetpointClient.GetDatesRangeAsync(token), token); return result!; } public async Task> GetPart(DateTimeOffset dateBegin, int take, CancellationToken token) { var result = await ExecuteGetResponse( async () => await refitSetpointClient.GetPart(dateBegin, take, token), token); return result!; } public async Task Add(Guid setpointKey, object newValue, CancellationToken token) { await ExecutePostResponse( async () => await refitSetpointClient.Add(setpointKey, newValue, token), token); } public void Dispose() { refitSetpointClient.Dispose(); GC.SuppressFinalize(this); } }