<?php

namespace App\Jobs;

use App\Services\GoogleSheetService;
use App\Services\ServiceSIMBG;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;

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

    public $tries = 1;

    public function __construct()
    {
    }

    public function handle(): void
    {
        try {
            $serviceSIMBG = app(ServiceSIMBG::class);
            $serviceSIMBG->syncTaskPBG();
        } catch (\Exception $e) {
            \Log::error("SyncronizeSIMBG Job Failed: " . $e->getMessage(), [
                'exception' => $e,
            ]);
            $this->fail($e); // Mark the job as failed
        }
    }
}
