<?php

namespace App\Listeners\V3\Dashboard\Harim;

use App\Events\V3\Dashboard\Harim\ConfirmGuaranteeLetterNeedEvent;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Http\Client\RequestException;
use Illuminate\Support\Facades\Http;

class ConfirmGuaranteeLetterNeedListener implements ShouldQueue
{
    /**
     * The name of the queue the job should be sent to.
     *
     * @var string|null
     */
    public ?string $queue = 'harim';

    protected string $url;
    protected string $password;
    protected string $username;

    public function __construct()
    {
        $this->url      = config('harim_web_services.reject.url');
        $this->username = config('harim_web_services.reject.username');
        $this->password = config('harim_web_services.reject.password');
    }

    /**
     * @throws RequestException
     */
    public function handle(ConfirmGuaranteeLetterNeedEvent $event): void
    {
        Http::post($this->url,
            array(
                ''  => $event->harim->id,
                ''  =>  $event->harim->id,
                ''  => $event->harim->id,
                ''    => $event->harim->id,
                '' =>  $event->harim->id,
                ''      =>  $event->harim->id,
                '' =>  $event->harim->id,
            ))->throw();
    }
}
