grafstorm / laravel-46elks-notification-channel
46 Elks Laravel Notification Channel
Fund package maintenance!
grafstorm
Requires
- php: ^8.0
- guzzlehttp/guzzle: ^7.3
- illuminate/contracts: ^8.0
- spatie/laravel-package-tools: ^1.4.3
Requires (Dev)
- orchestra/testbench: ^6.13
- phpunit/phpunit: ^9.3
- spatie/laravel-ray: ^1.9
- vimeo/psalm: ^4.4
This package is auto-updated.
Last update: 2024-10-29 06:19:31 UTC
README
Disclaimer: Not a finished package! If you are looking for a finished package to user for 46elks perhaps look at: https://github.com/laravel-notification-channels/46elks
Laravel SMS notification Channel for 46elks.se sms provider.
Installation
You can install the package via composer:
composer require grafstorm/laravel-46elks-notification-channel
Be sure to set User, Password and Sender in your .env file. Sender is limited to a alphaumeric string of maximum 11 characters([A-Za-z0-9]) or a correctly formatted E.164 phonenumber.
FORTY_SIX_ELKS_USER=::username:: FORTY_SIX_ELKS_PASS=::password:: FORTY_SIX_ELKS_FROM=::sender::
You can publish the config file if you want to override the default settings.
return [ 'user' => env('FORTY_SIX_ELKS_USER'), 'pass' => env('FORTY_SIX_ELKS_PASS'), 'from' => env('FORTY_SIX_ELKS_FROM', '46ELKS'), 'base_url' => env('FORTY_SIX_ELKS_BASE_URL', 'https://api.46elks.com/a1/') ];
You can publish the config file with:
php artisan vendor:publish --provider="Grafstorm\FortySixElksChannel\FortySixElksChannelServiceProvider" --tag="46elks-notification-channel-config"
Usage
Add Grafstorm\FortySixElksChannel\FortySixElksChannel::class
in the via method in your notification.
And be sure to add a toFortySixElks
method that returns an array with the mobile number and the message.
use Grafstorm\FortySixElksChannel\FortySixElksChannel; use Grafstorm\FortySixElksChannel\SmsMessage; /** * Get the notification's delivery channels. * * @param mixed $notifiable * @return array */ public function via($notifiable) { return [FortySixElksChannel::class]; } /** * Get the mail representation of the notification. * * @param mixed $notifiable * @return string[] */ public function toFortySixElks($notifiable): SmsMessage { // Return a SmsMessage. Needs to and message. // To needs to be formatted as a [E.164](https://en.wikipedia.org/wiki/E.164) phonenumber. (Eg. +4612345678) return (new SmsMessage()) ->from('developer') ->to($notifiable->mobile) ->line('Hello World') ->line('') ->line('Bye world.'); }
Sending a oneoff text message
You can also use the FortySixElks facade to send a message directly in your application.
use Grafstorm\FortySixElksChannel\SmsMessage; use Grafstorm\FortySixElksChannel\Facades\FortySixElks; $message = (new SmsMessage()) ->to('+461') ->line('Hello World'); $sms = FortySixElks::create($message)->send(); // Use dryRun() to test sending the message. $sms = FortySixElks::create($message)->dryRun()->send();
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.