<?php

declare(strict_types=1);

namespace App\Administration\Domain\Event;

use App\Shared\Domain\DomainEvent;
use App\Shared\Domain\Tenant\TenantId;
use DateTimeImmutable;
use Ramsey\Uuid\Uuid;
use Ramsey\Uuid\UuidInterface;

/**
 * Événement émis lors d'une connexion réussie.
 *
 * @see Story 1.4 - Connexion utilisateur
 */
final readonly class ConnexionReussie implements DomainEvent
{
    public function __construct(
        public string $userId,
        public string $email,
        public TenantId $tenantId,
        public string $ipAddress,
        public string $userAgent,
        public DateTimeImmutable $occurredOn,
    ) {
    }

    public function occurredOn(): DateTimeImmutable
    {
        return $this->occurredOn;
    }

    public function aggregateId(): UuidInterface
    {
        return Uuid::fromString($this->userId);
    }
}
