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

/// <summary>
/// Defines a callable HTTP method on an external system definition.
/// </summary>
public class ExternalSystemMethod
{
    /// <summary>Primary key.</summary>
    public int Id { get; set; }
    /// <summary>Foreign key referencing the owning <c>ExternalSystemDefinition</c>.</summary>
    public int ExternalSystemDefinitionId { get; set; }
    /// <summary>Name of the method as referenced in scripts.</summary>
    public string Name { get; set; }
    /// <summary>HTTP method (GET, POST, PUT, DELETE, etc.).</summary>
    public string HttpMethod { get; set; }
    /// <summary>URL path relative to the external system's base URL.</summary>
    public string Path { get; set; }
    /// <summary>JSON-serialized parameter definitions for this method, or null if there are none.</summary>
    public string? ParameterDefinitions { get; set; }
    /// <summary>JSON-serialized return type definition for this method, or null if void.</summary>
    public string? ReturnDefinition { get; set; }

    /// <summary>Initializes a new instance of <see cref="ExternalSystemMethod"/> with the required fields.</summary>
    /// <param name="name">The method name.</param>
    /// <param name="httpMethod">The HTTP method verb.</param>
    /// <param name="path">The URL path.</param>
    public ExternalSystemMethod(string name, string httpMethod, string path)
    {
        Name = name ?? throw new ArgumentNullException(nameof(name));
        HttpMethod = httpMethod ?? throw new ArgumentNullException(nameof(httpMethod));
        Path = path ?? throw new ArgumentNullException(nameof(path));
    }
}
