<?php

namespace App\Services\Notifications;

use App\Models\Customer;
use App\Models\ReminderNotificationLog;
use App\Notifications\LoanReminderNotification;
use Throwable;

class InSystemReminderProvider implements ReminderChannelProvider
{
    public function send(ReminderNotificationLog $log, Customer $customer): NotificationDeliveryResult
    {
        try {
            $customer->notify(new LoanReminderNotification($log));
            return NotificationDeliveryResult::delivered(json_encode(['transport'=>'database'], JSON_UNESCAPED_SLASHES));
        } catch (Throwable $e) {
            return NotificationDeliveryResult::failed($e->getMessage());
        }
    }
}
