<?php

namespace App\Modules\Integrations\Platform\Jobs;

use App\Modules\Integrations\Platform\Services\WebhookDeliveryExecutor;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;

final class DeliverWebhookJob implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    /**
     * High ceiling because retries use {@see \Illuminate\Queue\InteractsWithQueue::release()}.
     */
    public int $tries = 400;

    public function __construct(public readonly int $deliveryId) {}

    public function handle(WebhookDeliveryExecutor $executor): void
    {
        $executor->execute($this->deliveryId, $this);
    }
}
