toneflix-code / kudisms-notification
KUDI SMS Notifications Driver for Laravel.
Requires
- php: >= 8.1
- guzzlehttp/guzzle: ^7.0
- illuminate/notifications: ^9.0|^10.0|^11.0
- illuminate/support: ^9.0|^10.0|^11.0
- toneflix-code/kudi-sms-php: ^1.0
Requires (Dev)
- fakerphp/faker: ^1.21
- illuminate/contracts: ^9.0|^10.0|^11.0
- laravel/pint: ^1.0
- orchestra/testbench: ^8.8
- pestphp/pest: ^2.33
- pestphp/pest-plugin-laravel: ^2.0
README
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 gregoriohc@gmail.com 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.