using Newtonsoft.Json;

namespace NostrRelay;

public class Fees
{
    [JsonProperty("subscription")]
    public List<Subscription> Subscription { get; set; }
}

public class Limitation
{
    [JsonProperty("payment_required")]
    public bool? PaymentRequired { get; set; } = false;

    [JsonProperty("max_message_length")]
    public int? MaxMessageLength { get; set; }

    /// <summary>
    /// Maximum number of filter values in each subscription. Must be one or higher.
    /// </summary>
    [JsonProperty("max_filters")]
    public int? MaxFilters { get; init; } = 1;

    [JsonProperty("max_event_tags")]
    public int? MaxEventTags { get; set; }

    [JsonProperty("max_subscriptions")]
    public int? MaxSubscriptions { get; set; }

    [JsonProperty("auth_required")]
    public bool? AuthRequired { get; set; }
    
    [JsonProperty("restricted_writes")]
    public bool? RestrictedWrites { get; set; }
}

public class RelayDocument
{
    [JsonProperty("description")]
    public string? Description { get; set; }

    [JsonProperty("name")]
    public string? Name { get; set; }

    [JsonProperty("pubkey")]
    public string? Pubkey { get; set; }

    [JsonProperty("software")]
    public string? Software { get; set; }
    

    [JsonProperty("supported_nips")]
    public List<int>? SupportedNips { get; set; }

    [JsonProperty("version")]
    public string? Version { get; set; }

    /// <summary>
    /// A URL pointing to an image to be used as an icon for the relay
    /// </summary>
    [JsonProperty("icon")]
    public string? Icon { get; init; }
    
    [JsonProperty("limitation")]
    public Limitation? Limitation { get; set; }

    [JsonProperty("payments_url")]
    public string? PaymentsUrl { get; set; }

    [JsonProperty("fees")]
    public Fees? Fees { get; set; }

    [JsonProperty("relay_countries")]
    public List<string>? RelayCountries { get; init; }
    
    /// <summary>
    /// Ordered list of IETF language tags indicating the major languages spoken on the relay.
    /// </summary>
    [JsonProperty("language_tags")]
    public List<string>? LanguageTags { get; init; }
    
    [JsonProperty("tags")]
    public List<string>? Tags { get; init; }
    
    /// <summary>
    /// Link to a human-readable page which specifies the community policies for the relay
    /// </summary>
    [JsonProperty("posting_policy")]
    public string? PostingPolicy { get; set; }
}

public class Subscription
{
    [JsonProperty("amount")]
    public long? Amount { get; set; }

    [JsonProperty("unit")]
    public string Unit { get; set; } = "msats";

    [JsonProperty("period")]
    public int? Period { get; set; }
}
