using ZB.MOM.WW.ScadaBridge.Commons.Types.Enums;

namespace ZB.MOM.WW.ScadaBridge.Commons.Types.Audit;

/// <summary>
/// Builds the canonical <c>Action</c> and <c>Category</c> fields for
/// <c>ZB.MOM.WW.Audit.AuditEvent</c> from ScadaBridge's channel + kind enums.
/// </summary>
/// <remarks>
/// <para>
/// <list type="bullet">
///   <item><see cref="BuildAction"/> produces <c>"{channel}.{kind}"</c> — a stable dot-separated
///     identifier that maps directly onto the canonical <c>Action</c> field.</item>
///   <item><see cref="BuildCategory"/> produces <c>channel.ToString()</c> — a grouping token
///     that maps onto the canonical <c>Category</c> field.</item>
/// </list>
/// </para>
/// </remarks>
public static class AuditFieldBuilders
{
    /// <summary>
    /// Returns the canonical <c>Action</c> string: <c>"{channel}.{kind}"</c>.
    /// </summary>
    /// <param name="channel">The audit channel (e.g. ExternalSystem, Notification).</param>
    /// <param name="kind">The audit kind (e.g. Sync, Cached, InboundAuthFailure).</param>
    /// <returns>A dot-separated string in the form <c>"{channel}.{kind}"</c>.</returns>
    public static string BuildAction(AuditChannel channel, AuditKind kind)
        => $"{channel}.{kind}";

    /// <summary>
    /// Returns the canonical <c>Category</c> string: the channel name.
    /// </summary>
    /// <param name="channel">The audit channel whose name becomes the category.</param>
    /// <returns>The channel enum name as a string (e.g. <c>"ApiOutbound"</c>).</returns>
    public static string BuildCategory(AuditChannel channel)
        => channel.ToString();
}
