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; using DD.Persistence.Models.Requests; using DD.Persistence.Models.Common; namespace DD.Persistence.Client.Clients; public class TechMessagesClient : BaseClient, ITechMessagesClient { private readonly IRefitTechMessagesClient refitTechMessagesClient; public TechMessagesClient(IRefitClientFactory refitTechMessagesClientFactory, ILogger logger) : base(logger) { this.refitTechMessagesClient = refitTechMessagesClientFactory.Create(); } public async Task> GetPage(PaginationRequest request, CancellationToken token) { var result = await ExecuteGetResponse( async () => await refitTechMessagesClient.GetPage(request, token), token); return result!; } public async Task AddRange(Guid systemId, IEnumerable dtos, CancellationToken token) { var result = await ExecutePostResponse( async () => await refitTechMessagesClient.AddRange(systemId, dtos, token), token); return result; } public async Task> GetSystems(CancellationToken token) { var result = await ExecuteGetResponse( async () => await refitTechMessagesClient.GetSystems(token), token); return result!; } public async Task GetDatesRangeAsync(CancellationToken token) { var result = await ExecuteGetResponse( async () => await refitTechMessagesClient.GetDatesRangeAsync(token), token); return result; } public async Task> GetPart(DateTimeOffset dateBegin, int take, CancellationToken token) { var result = await ExecuteGetResponse( async () => await refitTechMessagesClient.GetPart(dateBegin, take, token), token); return result!; } public async Task> GetStatistics(IEnumerable systemIds, IEnumerable categoryIds, CancellationToken token) { var result = await ExecuteGetResponse( async () => await refitTechMessagesClient.GetStatistics(systemIds, categoryIds, token), token); return result!; } public void Dispose() { refitTechMessagesClient.Dispose(); GC.SuppressFinalize(this); } }