<?php

namespace App\Support\Channels;

use App\Contracts\NotificationChannelInterface;
use App\Models\User;
use App\Services\WhatsAppService;

class WhatsAppNotificationChannel implements NotificationChannelInterface
{
    public function __construct(
        protected ?WhatsAppService $whatsAppService = null
    ) {
        $this->whatsAppService = $whatsAppService ?? app(WhatsAppService::class);
    }

    public function send(User $recipient, string $title, string $message, string $type = 'info'): bool
    {
        $target = $recipient->phone_number;
        if (empty($target)) {
            return false;
        }

        return $this->whatsAppService->sendMessage($target, $title, $message);
    }
}
