using EventFlow.Aggregates;

namespace Books.Api.Domain.UserAccess.Events;

/// <summary>
/// Emitted when a user is granted access to a company.
/// </summary>
public class UserCompanyAccessGrantedEvent(
    string userId,
    string companyId,
    CompanyRole role,
    string grantedBy) : AggregateEvent<UserCompanyAccessAggregate, UserCompanyAccessId>
{
    public string UserId { get; } = userId;
    public string CompanyId { get; } = companyId;
    public CompanyRole Role { get; } = role;
    public string GrantedBy { get; } = grantedBy;
}

/// <summary>
/// Emitted when a user's role is changed for a company.
/// </summary>
public class UserCompanyAccessRoleChangedEvent(
    CompanyRole oldRole,
    CompanyRole newRole,
    string changedBy) : AggregateEvent<UserCompanyAccessAggregate, UserCompanyAccessId>
{
    public CompanyRole OldRole { get; } = oldRole;
    public CompanyRole NewRole { get; } = newRole;
    public string ChangedBy { get; } = changedBy;
}

/// <summary>
/// Emitted when a user's access to a company is revoked.
/// </summary>
public class UserCompanyAccessRevokedEvent(
    string revokedBy) : AggregateEvent<UserCompanyAccessAggregate, UserCompanyAccessId>
{
    public string RevokedBy { get; } = revokedBy;
}
