<?php

namespace App\Jobs;

use App\Services\Alerts\AlertEngine;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;

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

    public function __construct(
        public readonly ?int $clientId = null,
        public readonly ?int $ruleId = null,
        public readonly bool $notify = true,
    ) {
    }

    public function handle(AlertEngine $engine): void
    {
        $engine->evaluateAll($this->clientId, $this->ruleId, $this->notify);
    }
}
