<?php

namespace Maestro\Core\Events;

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

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

    /**
     * Get the channels the event should broadcast on.
     *
     * @return array<int, \Illuminate\Broadcasting\PrivateChannel>
     */
    public function broadcastOn(): array
    {
        return [
            new PrivateChannel('user.notifications.' . $this->userId),
        ];
    }

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

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

