using JSMR.Infrastructure.Integrations.DLSite.Models;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace JSMR.Infrastructure.Integrations.DLSite.Serialization;

[JsonSerializable(typeof(ProductInfoCollection))]
[JsonSourceGenerationOptions(PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase)]
public partial class DLSiteJsonContext : JsonSerializerContext
{
    public static JsonSerializerOptions CreateOptions()
    {
        JsonSerializerOptions options = new(JsonSerializerDefaults.Web);
        options.Converters.Add(new NumberConverter());
        options.Converters.Add(new DictionaryConverter<string, decimal>());
        options.Converters.Add(new DictionaryConverter<string, string>());
        options.Converters.Add(new DateTimeConverterUsingDateTimeParse());
        options.Converters.Add(new NullableDateTimeConverterUsingDateTimeParse());
        options.Converters.Add(new ProductInfoOptionsConverter());

        return options;
    }
}