feat(EConnectClientOptions): created and inject

This commit is contained in:
Developer 02 2025-08-14 17:49:04 +02:00
parent c6ec3ca054
commit 2e59c090a8
2 changed files with 11 additions and 1 deletions

View File

@ -1,17 +1,21 @@
using Leanetec.EConnect.Client.Interface;
using Leanetec.EConnect.Domain.Entities;
using Microsoft.Extensions.Options;
using System.Net.Http.Json;
namespace Leanetec.EConnect.Infrastructure;
public class EConnectClient<TError> : IEConnectClient<TError> where TError : class
{
private readonly EConnectClientOptions _options;
private readonly Lazy<HttpClient> LazyHttp;
private HttpClient Http => LazyHttp.Value;
public EConnectClient(IHttpClientFactory httpFactory)
public EConnectClient(IOptions<EConnectClientOptions> options, IHttpClientFactory httpFactory)
{
_options = options.Value;
LazyHttp = new Lazy<HttpClient>(httpFactory.CreateEConnectClient);
}

View File

@ -0,0 +1,6 @@
namespace Leanetec.EConnect.Infrastructure;
public class EConnectClientOptions
{
public string? ApiKey { get; set; }
}