<?php

namespace App\Jobs;

use App\Jobs\Tasks\CrawlUrlResearchTask;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;

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

    protected $serp_url_research_id;

    public $timeout = 15;

    /**
     * Create a new job instance.
     */
    public function __construct($serp_url_research_id)
    {
        $this->serp_url_research_id = $serp_url_research_id;
    }

    /**
     * Execute the job.
     */
    public function handle(): void
    {
        if (! is_null($this->serp_url_research_id)) {
            CrawlUrlResearchTask::handle($this->serp_url_research_id);
        }
    }
}
