Skip to content

toneflix/kudisms-notification

Repository files navigation

KUDI SMS Notifications channel for Laravel

Test & Lint Latest Stable Version Total Downloads Latest Unstable Version License PHP Version Require codecov

This package makes it easy to send KudiSMS notifications with Laravel 8.x, 9.x & 10.x

Contents

Installation

You can install the package via composer:

composer require toneflix-code/kudisms-notification

Configuration

Add your KudiSMS Account token, SenderId, and CallerId (optional) to your .env:

KUDISMS_GATEWAY= # optional
KUDISMS_API_KEY=ZYX # always required
KUDISMS_SENDER_ID=ABCD # always required
KUDISMS_CALLER_ID=ABCD # optional when sender id is set
KUDISMS_TEST_NUMBERS=23423423423,12312312312 # Comma separated list of numbers to send messages to when running tests

Advanced configuration

Run php artisan vendor:publish --provider="ToneflixCode\KudiSmsNotification\KudiSmsProvider"

/config/kudi-notification.php

Usage

Now you can use the channel in your via() method inside the notification:

use ToneflixCode\KudiSmsNotification\KudiSmsChannel;
use ToneflixCode\KudiSmsNotification\KudiSmsMessage;
use Illuminate\Notifications\Notification;

class AccountApproved extends Notification
{
    public function via($notifiable)
    {
        return [KudiSmsChannel::class];
    }

    public function toKudiSms($notifiable)
    {
        return (new KudiSmsMessage())
            ->message("Your {$notifiable->service} account was approved!");
    }
}

You can also create a Kudi voice call:

use ToneflixCode\KudiSmsNotification\KudiSmsChannel;
use ToneflixCode\KudiSmsNotification\KudiSmsVoiceMessage;
use Illuminate\Notifications\Notification;

class AccountApproved extends Notification
{
    public function via($notifiable)
    {
        return [KudiSmsChannel::class];
    }

    public function toTwilio($notifiable)
    {
        return (new KudiSmsVoiceMessage())
            ->url("https://download.samplelib.com/mp3/sample-3s.mp3");
    }
}

Or create a Kudi Text To Speach call:

use ToneflixCode\KudiSmsNotification\KudiSmsChannel;
use ToneflixCode\KudiSmsNotification\KudiSmsTTSMessage;
use Illuminate\Notifications\Notification;

class AccountApproved extends Notification
{
    public function via($notifiable)
    {
        return [KudiSmsChannel::class];
    }

    public function toTwilio($notifiable)
    {
        return (new KudiSmsTTSMessage())
            ->message("Hello {$notifiable->name}, how are you today?");
    }
}

In order to let your Notification know which phone are you sending/calling to, the channel will look for the phone_number attribute of the Notifiable model. If you want to override this behaviour, add the routeNotificationForKudiSms method to your Notifiable model.

public function routeNotificationForKudiSms()
{
    return '+2349034567890';
}

Available Message methods

KudiSmsMessage

  • senderId(''): Accepts a registered SenderId to use as the notification sender.
  • message(''): Accepts a string value for the notification body.

KudiSmsVoiceMessage

  • callerId(''): Accepts a registered CallerId to use as the notification sender.
  • url(''): Accepts a url of a publicly available audio file.

KudiSmsTTSMessage

  • callerId(''): Accepts a registered CallerId to use as the notification sender.
  • message(''): Accepts a string value for the notification body.

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

$ composer test

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.

About

KUDI SMS Notifications Driver for Laravel

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages