<?php

namespace App\Services\Notifications;

use App\Models\Customer;
use App\Models\ReminderNotificationLog;

class SmsReminderProvider implements ReminderChannelProvider
{
    public function __construct(private NextSmsService $nextSms) {}

    public function send(ReminderNotificationLog $log, Customer $customer): NotificationDeliveryResult
    {
        $business=$log->business()->first();

        if($business && filled($business->nextsms_api_key) && filled($business->nextsms_sender_id)) {
            return $this->nextSms->send($business,(string)$log->recipient,(string)$log->message);
        }

        // Backward-compatible fallback for installations that still use the older generic SMS HTTP endpoint.
        return (new HttpReminderProvider('sms'))->send($log,$customer);
    }
}
