namespace Journal.Core.Models;

public class Conversation
{
    public Guid Id { get; }
    public string Title { get; set; }
    public DateTimeOffset CreatedAt { get; set; }
    public DateTimeOffset UpdatedAt { get; set; }

    public Conversation(string title)
    {
        if (string.IsNullOrWhiteSpace(title))
            throw new ArgumentException("Title is required", nameof(title));

        Id = Guid.NewGuid();
        Title = title.Trim();
        CreatedAt = DateTimeOffset.Now;
        UpdatedAt = CreatedAt;
    }

    public Conversation(Guid id, string title, DateTimeOffset createdAt, DateTimeOffset updatedAt)
    {
        if (id == Guid.Empty)
            throw new ArgumentException("Id is required", nameof(id));
        if (string.IsNullOrWhiteSpace(title))
            throw new ArgumentException("Title is required", nameof(title));

        Id = id;
        Title = title.Trim();
        CreatedAt = createdAt;
        UpdatedAt = updatedAt;
    }
}
