<?php

namespace App\Jobs;

use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Queue\Queueable;
use Log;
use App\ContraparteCalls;

/*
    Esta clase debe mantenerse idéntica a la que hay en el repo de clientes
*/
class ContraparteCallsQueue implements ShouldQueue
{
    use Queueable;

    private $cuit;
    private $cuil;
    private $es_empleador;

    /**
     * Create a new job instance.
     */
    public function __construct($cuit, $cuil = null, $es_empleador = false)
    {
        $this->cuit = $cuit;
        $this->cuil = $cuil;
        $this->es_empleador = $es_empleador;
    }

    /**
     * Execute the job.
     */
    public function handle(): void
    {
        if (!$this->es_empleador) {
            $calls = new ContraparteCalls($this->cuit);
        } else {
            $calls = new ContraparteCalls($this->cuit, $this->cuil);
        }
        
        $calls->enriquecerAportes();
        $calls->enriquecerConstancia();
        // Log::info('Procesando las llamadas del CUIT: '.$this->cuit);
        // Log::channel('mongo_queue_log')->info('Procesando las llamadas del CUIT: '.$this->cuit);
    }
}