<?php

namespace App\Jobs;

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

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

    protected $serp_url;

    public $timeout = 600;

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

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