using DD.Persistence.Client.Helpers; using Microsoft.Extensions.Logging; using Refit; namespace DD.Persistence.Client.Clients.Base; public abstract class BaseClient { private readonly ILogger logger; public BaseClient(ILogger logger) { this.logger = logger; } public async Task ExecuteGetResponse(Func>> getMethod, CancellationToken token) { var response = await getMethod.Invoke().WaitAsync(token); if (response.IsSuccessStatusCode) { return response.Content; } var exception = response.GetPersistenceException(); logger.LogError(exception.Message); throw exception; } public async Task ExecutePostResponse(Func> postMethod, CancellationToken token) { var response = await postMethod.Invoke().WaitAsync(token); if (response.IsSuccessStatusCode) { return; } var exception = response.GetPersistenceException(); logger.LogError(exception.Message); throw exception; } public async Task ExecutePostResponse(Func>> postMethod, CancellationToken token) { var response = await postMethod.Invoke().WaitAsync(token); if (response.IsSuccessStatusCode) { return response.Content; } var exception = response.GetPersistenceException(); logger.LogError(exception.Message); throw exception; } }