using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;

namespace Nalu.Web.Data.Models;

public class Subscription
{
    [BsonId]
    [BsonRepresentation(BsonType.ObjectId)]
    public string Id { get; set; } = ObjectId.GenerateNewId().ToString();

    [BsonElement("user_id")]
    public required string UserId { get; set; }

    [BsonElement("stripe_subscription_id")]
    public required string StripeSubscriptionId { get; set; }

    [BsonElement("stripe_customer_id")]
    public required string StripeCustomerId { get; set; }

    [BsonElement("plan")]
    public required string Plan { get; set; }

    /// "active" | "canceled" | "past_due" | "trialing"
    [BsonElement("status")]
    public string Status { get; set; } = "active";

    [BsonElement("current_period_start")]
    public DateTime CurrentPeriodStart { get; set; }

    [BsonElement("current_period_end")]
    public DateTime CurrentPeriodEnd { get; set; }

    [BsonElement("cancel_at_period_end")]
    public bool CancelAtPeriodEnd { get; set; }

    [BsonElement("created_at")]
    public DateTime CreatedAt { get; set; } = DateTime.UtcNow;

    [BsonElement("updated_at")]
    public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
}
