using System.Text.Json; using Microsoft.Extensions.Configuration; using Persistence.Client.Helpers; using Persistence.Models.Configurations; using Refit; namespace Persistence.Client { public class PersistenceClientFactory { private static readonly JsonSerializerOptions JsonSerializerOptions = new() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase, PropertyNameCaseInsensitive = true }; private static readonly RefitSettings RefitSettings = new(new SystemTextJsonContentSerializer(JsonSerializerOptions)); private HttpClient httpClient; public PersistenceClientFactory(IHttpClientFactory httpClientFactory, IConfiguration configuration) { this.httpClient = httpClientFactory.CreateClient(); httpClient.Authorize(configuration); } public T GetClient() { return RestService.For(httpClient, RefitSettings); } } }