<?php

declare(strict_types=1);

namespace Maestro\Core\Events;

use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;

final class DataTableExportReady implements ShouldBroadcastNow
{
    public function __construct(
        public string $userId,
        public string $exportId,
        public string $resourceKey,
    ) {}

    /**
     * @return array<int, PrivateChannel>
     */
    public function broadcastOn(): array
    {
        return [
            new PrivateChannel('user.notifications.'.$this->userId),
        ];
    }

    public function broadcastAs(): string
    {
        return 'ExportReady';
    }

    /**
     * @return array<string, mixed>
     */
    public function broadcastWith(): array
    {
        return [
            'exportId' => $this->exportId,
            'resourceKey' => $this->resourceKey,
            'type' => 'export-ready',
        ];
    }
}
