<?php

namespace App\Jobs;

use App\Models\GeneratedReport;
use App\Services\Mail\ReportMailer;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;

class SendReportEmailJob implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    /**
     * @param array<string, mixed> $options
     */
    public function __construct(public int $reportId, public array $options = [])
    {
    }

    public function handle(ReportMailer $mailer): void
    {
        $report = GeneratedReport::findOrFail($this->reportId);
        $mailer->sendReport($report, $this->options);
    }
}
