namespace ZB.MOM.WW.ScadaBridge.Commons.Entities.ExternalSystems;

public class ExternalSystemDefinition
{
    /// <summary>Database primary key.</summary>
    public int Id { get; set; }
    /// <summary>Display name for the external system.</summary>
    public string Name { get; set; }
    /// <summary>Base URL of the external system's HTTP endpoint.</summary>
    public string EndpointUrl { get; set; }
    /// <summary>Authentication type identifier (e.g., "ApiKey", "Basic").</summary>
    public string AuthType { get; set; }
    /// <summary>JSON-serialized authentication configuration for the selected <see cref="AuthType"/>.</summary>
    public string? AuthConfiguration { get; set; }
    /// <summary>Maximum number of retry attempts for transient failures.</summary>
    public int MaxRetries { get; set; }
    /// <summary>Fixed delay between retry attempts.</summary>
    public TimeSpan RetryDelay { get; set; }

    /// <summary>
    /// Per-system HTTP round-trip timeout in seconds for all method calls
    /// (spec: Component-ExternalSystemGateway "Timeout"). 0 = unset — the gateway's
    /// configured DefaultHttpTimeout applies.
    /// </summary>
    public int TimeoutSeconds { get; set; }

    /// <summary>
    /// Initializes a new <see cref="ExternalSystemDefinition"/>.
    /// </summary>
    /// <param name="name">Display name for the external system.</param>
    /// <param name="endpointUrl">Base URL of the external system's HTTP endpoint.</param>
    /// <param name="authType">Authentication type identifier.</param>
    public ExternalSystemDefinition(string name, string endpointUrl, string authType)
    {
        Name = name ?? throw new ArgumentNullException(nameof(name));
        EndpointUrl = endpointUrl ?? throw new ArgumentNullException(nameof(endpointUrl));
        AuthType = authType ?? throw new ArgumentNullException(nameof(authType));
    }
}
