<?php

declare(strict_types=1);

namespace App\Notifications\Payments;

use App\Models\Transaction;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Notification;

final class PaymentInstructionsSent extends Notification implements ShouldQueue
{
    use Queueable;

    public function __construct(
        public Transaction $transaction
    ) {}

    /**
     * Get the notification's delivery channels.
     *
     * @return array<int, string>
     */
    public function via(object $notifiable): array
    {
        return ['database'];
    }

    /**
     * Get the array representation of the notification.
     *
     * @return array<string, mixed>
     */
    public function toArray(object $notifiable): array
    {
        $methodName = match ($this->transaction->payment_method) {
            'bank_transfer' => 'Bank Transfer',
            'crypto' => 'Cryptocurrency',
            'paypal' => 'PayPal',
            default => 'Payment',
        };

        return [
            'title' => 'Payment Instructions',
            'message' => 'Complete your payment for '.$this->transaction->property->title.' via '.$methodName,
            'icon' => 'banknotes',
            'url' => route('guest.payments.show', $this->transaction->id),
            'transaction_id' => $this->transaction->id,
            'booking_id' => $this->transaction->booking_id,
        ];
    }
}
