<?php

use App\Application\Services\Webhooks\WebhookDestinationValidator;
use App\Application\Services\Webhooks\WebhookRetryPolicy;
use App\Jobs\DeliverMerchantWebhookJob;
use Illuminate\Contracts\Console\Kernel;

require __DIR__.'/../../vendor/autoload.php';

$app = require __DIR__.'/../../bootstrap/app.php';
$app->make(Kernel::class)->bootstrap();

$ids = array_slice($argv, 1);

foreach ($ids as $id) {
    app(DeliverMerchantWebhookJob::class, ['deliveryId' => (int) $id])
        ->handle(app(WebhookRetryPolicy::class), app(WebhookDestinationValidator::class));
    echo "Delivered/attempted webhook {$id}\n";
}
