namespace PowderCoating.Core.Entities;

/// <summary>
/// Persists every incoming Stripe webhook event for auditing and debugging.
/// Not a BaseEntity — platform-wide, no soft delete, no tenant filter.
/// </summary>
public class StripeWebhookEvent
{
    public long Id { get; set; }

    /// <summary>Stripe event ID (evt_...).</summary>
    public string EventId { get; set; } = string.Empty;

    /// <summary>Stripe event type string (e.g. customer.subscription.updated).</summary>
    public string EventType { get; set; } = string.Empty;

    /// <summary>Linked company, if resolvable from the event payload.</summary>
    public int? CompanyId { get; set; }

    /// <summary>Full raw JSON body of the event.</summary>
    public string RawJson { get; set; } = string.Empty;

    public StripeWebhookEventStatus Status { get; set; } = StripeWebhookEventStatus.Received;

    public string? ErrorMessage { get; set; }

    public DateTime ReceivedAt { get; set; } = DateTime.UtcNow;

    public DateTime? ProcessedAt { get; set; }
}

public enum StripeWebhookEventStatus
{
    Received = 0,
    Processed = 1,
    Failed = 2,
    Ignored = 3
}
