using Knot.Contracts.Relations.Domain;
using Knot.Shared.Kernel;

namespace Knot.Modules.Relations.Domain;

public sealed class Friendship : Entity<Guid>
{
    public Guid UserId { get; private set; }
    public Guid FriendId { get; private set; }
    public FriendshipStatus Status { get; private set; }
    public DateTime CreatedAt { get; private set; }

    private Friendship(Guid id, Guid userId, Guid friendId, FriendshipStatus status) : base(id)
    {
        UserId = userId;
        FriendId = friendId;
        Status = status;
        CreatedAt = DateTime.UtcNow;
    }

    public static Friendship Create(Guid userId, Guid friendId)
    {
        return new Friendship(Guid.NewGuid(), userId, friendId, FriendshipStatus.Pending);
    }

    public void Accept() => Status = FriendshipStatus.Accepted;
    public void Decline() => Status = FriendshipStatus.Declined;
}
