2025-02-09 12:36:37 +01:00
|
|
|
using System.Text.Json;
|
|
|
|
|
using System.Text.Json.Serialization;
|
|
|
|
|
|
2025-03-11 13:57:47 +01:00
|
|
|
using AIStudio.Settings;
|
|
|
|
|
|
2025-02-09 12:36:37 +01:00
|
|
|
namespace AIStudio.Tools.ERIClient;
|
|
|
|
|
|
2025-03-11 13:57:47 +01:00
|
|
|
public abstract class ERIClientBase(IERIDataSource dataSource) : IDisposable
|
2025-02-09 12:36:37 +01:00
|
|
|
{
|
2026-04-16 16:48:47 +02:00
|
|
|
protected readonly IERIDataSource DataSource = dataSource;
|
2025-03-11 13:57:47 +01:00
|
|
|
|
2025-02-09 12:36:37 +01:00
|
|
|
protected static readonly JsonSerializerOptions JSON_OPTIONS = new()
|
|
|
|
|
{
|
|
|
|
|
WriteIndented = true,
|
|
|
|
|
AllowTrailingCommas = true,
|
2025-03-08 11:14:20 +01:00
|
|
|
PropertyNameCaseInsensitive = true,
|
2025-03-06 21:02:21 +01:00
|
|
|
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
|
2025-02-09 12:36:37 +01:00
|
|
|
DictionaryKeyPolicy = JsonNamingPolicy.CamelCase,
|
2025-03-08 11:14:20 +01:00
|
|
|
UnmappedMemberHandling = JsonUnmappedMemberHandling.Disallow,
|
2025-02-09 12:36:37 +01:00
|
|
|
Converters =
|
|
|
|
|
{
|
|
|
|
|
new JsonStringEnumConverter(JsonNamingPolicy.SnakeCaseUpper),
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2026-05-31 18:46:54 +02:00
|
|
|
protected readonly HttpClient HttpClient = ExternalHttpClientTimeout.CreateHttpClient(new Uri($"{dataSource.Hostname}:{dataSource.Port}"), ExternalHttpTrustPolicy.ALLOW_CUSTOM_ROOTS_WHEN_HOST_WHITELISTED);
|
2025-02-09 12:36:37 +01:00
|
|
|
|
2026-04-16 16:48:47 +02:00
|
|
|
protected string SecurityToken = string.Empty;
|
2025-02-09 12:36:37 +01:00
|
|
|
|
|
|
|
|
#region Implementation of IDisposable
|
|
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
2026-04-16 16:48:47 +02:00
|
|
|
this.HttpClient.Dispose();
|
2025-02-09 12:36:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|