namespace ZB.MOM.WW.MxGateway.Server.Security.Authentication;

public sealed record ApiKeyVerificationResult(
    bool Succeeded,
    ApiKeyIdentity? Identity,
    ApiKeyVerificationFailure Failure)
{
    /// <summary>
    /// Creates a successful verification result.
    /// </summary>
    /// <param name="identity">API key identity.</param>
    /// <returns>Success result.</returns>
    public static ApiKeyVerificationResult Success(ApiKeyIdentity identity)
    {
        return new ApiKeyVerificationResult(
            Succeeded: true,
            Identity: identity,
            Failure: ApiKeyVerificationFailure.None);
    }

    /// <summary>
    /// Creates a failed verification result.
    /// </summary>
    /// <param name="failure">Verification failure reason.</param>
    /// <returns>Failure result.</returns>
    public static ApiKeyVerificationResult Fail(ApiKeyVerificationFailure failure)
    {
        return new ApiKeyVerificationResult(
            Succeeded: false,
            Identity: null,
            Failure: failure);
    }
}
