<?php

namespace App\Jobs;

use App\Services\OrderPlacementNotificationService;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;

class SendOrderPlacementNotificationsJob implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    public int $tries = 3;

    public int $timeout = 120;

    public function __construct(
        public readonly int $orderId,
        public readonly string $channel,
        public readonly ?int $staffId = null,
    ) {
    }

    public function backoff(): array
    {
        return [10, 30, 90];
    }

    public function handle(OrderPlacementNotificationService $notificationService): void
    {
        $notificationService->sendPlacementNotifications($this->orderId, $this->channel, $this->staffId);
    }
}
