using System.Text.Json;

namespace Leanetec.EConnect.Infrastructure;

public class ClientOptions
{
    public string? BaseAddress { get; set; }

    public TimeSpan? Timeout { get; set; }

    public Dictionary<string, string?>? DefaultQueryStrings { get; set; }

    public Action<HttpClient>? AfterHttpInit { get; set; }

    private string? _jsonSerializerDateFormat = null;

    public string? JsonSerializerDateFormat
    {
        get => _jsonSerializerDateFormat;
        set
        {
            _jsonSerializerDateFormat = value;
            if (value is not null)
            {
                JsonSerializerOptions.Converters.Add(new DateTimeConverter(value));
            }
        }
    }

    public JsonSerializerOptions JsonSerializerOptions { get; set; } = new()
    {
        PropertyNameCaseInsensitive = true
    };
}