<?php

declare(strict_types=1);

namespace App\Modules\Leads\WebPage\Domain;

use App\Modules\Shared\Domain\Bus\Event\BusEvent;

final class WebPageCreatedDomainEvent extends BusEvent
{
    public function __construct(
        int $id,
        private string $name,
        private string $domain,
        private string $description,
        private int $version,
        private int $status,
        private int $idAdmin,
        private int $idLanguage,
        string $eventId = null,
        string $occurredOn = null
    ) {
        parent::__construct($id, $eventId, $occurredOn);
    }

    public static function eventName(): string
    {
        return 'route.created';
    }

    public static function fromPrimitives(
        int $aggregateId,
        array $body,
        string $eventId,
        string $occurredOn
    ): BusEvent {
        return new self(
            $aggregateId,
            $body['name'],
            $body['domain'],
            $body['description'],
            $body['version'],
            $body['status'],
            $body['idAdmin'],
            $body['idLanguage'],
            $eventId,
            $occurredOn
        );
    }

    public function toPrimitives(): array
    {
        return [
            'name' => $this->name,
            'domain' => $this->domain,
            'description' => $this->description,
            'version' => $this->version,
            'status' => $this->status,
            'idAdmin' => $this->idAdmin,
            'idLanguage' => $this->idLanguage,
        ];
    }

    public function name(): string
    {
        return $this->name;
    }
    public function domain(): string
    {
        return $this->domain;
    }
    public function description(): string
    {
        return $this->description;
    }
    public function version(): int
    {
        return $this->version;
    }

    public function status(): int
    {
        return $this->status;
    }
    public function idAdmin(): int
    {
        return $this->idAdmin;
    }
    public function idLanguage(): int
    {
        return $this->idLanguage;
    }
}
