<?php

declare(strict_types=1);

namespace ImovelZapAi\Publishing\Application\Data;

use Carbon\CarbonInterface;
use ImovelZapAi\Publishing\Domain\Enums\PublicationLogEvent;
use ImovelZapAi\Publishing\Domain\Enums\PublicationLogLevel;

final readonly class PropertyPublicationHistoryItemData
{
    public function __construct(
        public string $id,
        public string $publisherName,
        public PublicationLogEvent $event,
        public string $eventLabel,
        public PublicationLogLevel $level,
        public string $message,
        public ?string $actorName,
        public int $attempt,
        public ?string $externalUrl,
        public ?string $error,
        public CarbonInterface $occurredAt,
    ) {}

    public function occurredAtLabel(): string
    {
        return $this->occurredAt->timezone(config('app.timezone'))->format('d/m/Y H:i');
    }
}
