<?php

namespace App\Jobs;

use App\Services\ReportGenerator;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Queue\Queueable as QueueableTrait;
use Illuminate\Queue\SerializesModels;

class GenerateReport implements ShouldQueue
{
    use QueueableTrait, Queueable, SerializesModels;

    public int $timeout = 300;
    public int $tries = 1;

    public function __construct(
        public string $type,
        public ?string $period = null,
        public ?int $authorId = null,
    ) {}

    public function handle(ReportGenerator $generator): void
    {
        $generator->generate($this->type, $this->period, $this->authorId);
    }
}
