using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace StellaOps.Authority.Revocation;

internal sealed class RevocationEntryModel
{
    [JsonPropertyName("id")]
    [JsonPropertyOrder(1)]
    public required string Id { get; init; }

    [JsonPropertyName("category")]
    [JsonPropertyOrder(2)]
    public required string Category { get; init; }

    [JsonPropertyName("tokenType")]
    [JsonPropertyOrder(3)]
    [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
    public string? TokenType { get; init; }

    [JsonPropertyName("subjectId")]
    [JsonPropertyOrder(4)]
    [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
    public string? SubjectId { get; init; }

    [JsonPropertyName("clientId")]
    [JsonPropertyOrder(5)]
    [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
    public string? ClientId { get; init; }

    [JsonPropertyName("reason")]
    [JsonPropertyOrder(6)]
    [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
    public string? Reason { get; init; }

    [JsonPropertyName("reasonDescription")]
    [JsonPropertyOrder(7)]
    [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
    public string? ReasonDescription { get; init; }

    [JsonPropertyName("revokedAt")]
    [JsonPropertyOrder(8)]
    public DateTimeOffset RevokedAt { get; init; }

    [JsonPropertyName("effectiveAt")]
    [JsonPropertyOrder(9)]
    [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
    public DateTimeOffset? EffectiveAt { get; init; }

    [JsonPropertyName("expiresAt")]
    [JsonPropertyOrder(10)]
    [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
    public DateTimeOffset? ExpiresAt { get; init; }

    [JsonPropertyName("scopes")]
    [JsonPropertyOrder(11)]
    [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
    public List<string>? Scopes { get; init; }

    [JsonPropertyName("fingerprint")]
    [JsonPropertyOrder(12)]
    [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
    public string? Fingerprint { get; init; }

    [JsonPropertyName("metadata")]
    [JsonPropertyOrder(13)]
    [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
    public SortedDictionary<string, string?>? Metadata { get; init; }
}
