<?php

namespace App\Domains\Notification\Listeners;

use App\Domains\Notification\Services\NotificationMailService;
use App\Domains\Purchase\Events\PurchasePaid;
use Illuminate\Contracts\Queue\ShouldQueueAfterCommit;
use Illuminate\Queue\InteractsWithQueue;

class SendPurchaseConfirmedEmail implements ShouldQueueAfterCommit
{
    use InteractsWithQueue;

    public string $queue = 'emails';

    public int $tries = 3;

    /** @var array<int, int> */
    public array $backoff = [30, 120, 300];

    public function handle(PurchasePaid $event): void
    {
        app(NotificationMailService::class)->sendPurchaseConfirmed($event->purchaseId);
    }
}
