<?php

declare(strict_types=1);

namespace ImovelZapAi\ClientPortal\Infrastructure\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use ImovelZapAi\ClientPortal\Application\Actions\CompleteDocumentScanAction;

final class ScanPortalDocumentJob implements ShouldQueue
{
    use Dispatchable;
    use InteractsWithQueue;
    use Queueable;
    use SerializesModels;

    public int $tries = 2;

    public function __construct(
        public readonly string $uploadedDocumentId,
    ) {
        $this->onQueue((string) config('client_portal.queue', 'client-portal'));
    }

    public function handle(CompleteDocumentScanAction $action): void
    {
        // Stub: integração real de antivírus em sprint futuro.
        $action->execute($this->uploadedDocumentId, infected: false);
    }
}
