#nullable enable
using Baya.Domain.Common;

namespace Baya.Domain.Entities.Verification;

/// <summary>
/// One step per nurse per pipeline step-type. Carries the raw KYC-vendor payload
/// (<see cref="ExternalResponseJson"/>) for audit, an optional <see cref="ExpiresAt"/> for time-limited
/// steps, and a <b>snapshot</b> of the step-type's automation flag (<see cref="IsAutomated"/>) — read the
/// snapshot, never the live step-type, so historical records survive later catalog edits.
/// </summary>
public class VerificationStep : BaseEntity<long>
{
    public long NurseVerificationId { get; set; }
    public NurseVerification NurseVerification { get; set; } = null!;

    public long StepTypeId { get; set; }
    public VerificationStepType StepType { get; set; } = null!;

    public VerificationStepStatus Status { get; set; } = VerificationStepStatus.Pending;

    /// <summary>Raw KYC-vendor response, kept so the audit trail survives the mock→real swap.</summary>
    public string? ExternalResponseJson { get; set; }

    /// <summary>When a time-limited step lapses (criminal-record especially); the scanner reverts on it.</summary>
    public DateTimeOffset? ExpiresAt { get; set; }

    /// <summary>Snapshotted from the step-type at seed time — never re-read from the live step-type.</summary>
    public bool IsAutomated { get; set; }

    public DateTimeOffset? StartedAt { get; set; }
    public DateTimeOffset? CompletedAt { get; set; }

    public string? FailureReason { get; set; }

    public ICollection<VerificationDocument> Documents { get; set; } = new List<VerificationDocument>();
}
