<?php

namespace App\Notifications\Api\App;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;

class GiftNotification extends Notification
{
    use Queueable;

    protected $via;
    protected $transaction_id;
    private $title, $body;

    /**
     * Create a new notification instance.
     *
     * @return void
     */
    public function __construct($transaction_id, $amount, $via)
    {
        $this->via            = $via;
        $this->transaction_id = $transaction_id;

        $this->title   = [
            'ar' => trans("🎉 Congratulations! You've Won a Gift! 🎁", [], 'ar'),
            'en' => trans("🎉 Congratulations! You've Won a Gift! 🎁", [], 'en'),
        ];
        
        $this->body    = [
            'ar' => trans("Thank you for parking your scooter in a designated area. You've earned :amount as a reward!", ['amount' => $amount], 'ar'),
            'en' => trans("Thank you for parking your scooter in a designated area. You've earned :amount as a reward!", ['amount' => $amount], 'en'),
        ];
    }

    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        return $this->via;
    }

    public function toFcm($notifiable)
    {
        return [
            'notify_type'   => 'wallet',
            'notify_id'     => $this->transaction_id,
            'notify_status' => "gift_notification",
            'title'         => $this->title[$notifiable->locale ?? 'en'],
            'body'          => $this->body[$notifiable->locale ?? 'en'],
            'sender_data'   => auth('api')->user()?->only(['id', 'full_name', 'avatar']),
        ];
    }

    /**
     * Get the array representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function toArray($notifiable)
    {
        return [
            'notify_type'   => 'wallet',
            'notify_id'     => $this->transaction_id,
            'notify_status' => "gift_notification",
            'title'         => $this->title,
            'body'          => $this->body,
            'sender_data'   => auth('api')->user()?->only(['id', 'full_name', 'avatar']),
        ];
    }
}
