Skip to content

RicardoRamirezR/infobip

 
 

Repository files navigation

Infobip notification channel for Laravel 5.4 via SMS

Latest Version on Packagist Software License Build Status StyleCI SensioLabsInsight Quality Score Code Coverage Total Downloads

This package makes it easy to send notifications using Infobip with Laravel 5.4.

With this package you can send SMSs notifications.

Contents

Installation

You can install the package via composer:

composer require laravel-notification-channels/infobip

You must install the service provider:

// config/app.php
'providers' => [
    ...
    NotificationChannels\Infobip\InfobipServiceProvider::class,
],

Setting up the Infobip service

To create an Infobip account see Infobip docs

Add your Infobip REST API key to your config/services.php:

// config/services.php
...
'infobip' => [
    'key' => env('INFOBIP_KEY'),
    'apiKey' => env('INFOBIP_API_KEY'),
    'username' => env('INFOBIP_USERNAME'),
    'password' => env('INFOBIP_PASSWORD'),
],
...

On production you only need apiKey and add key for reference.

On development setting username and password facilitates the API keys management not asking for your credentials every time.

Generate an API key

php artisan infobip:create-api-key name --permissions=ALL

and set publicApiKey in config/services.php as apiKey

Commands

php artisan list infobip

Usage

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

use NotificationChannels\Infobip\InfobipChannel;
use NotificationChannels\Infobip\InfobipSmsMessage;
use Illuminate\Notifications\Notification;

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

    public function toInfobip($notifiable)
    {
        return (new InfobipSmsMessage())
            ->content("Your {$notifiable->last_invoice} was generated!");
    }
}

Infobip channel will look for a routeNotificationForInfobip method on your Notifiable model first then for the phone_number or mobil attribute of the Notifiable model to get the destination number. Remember to add the country code.

public function routeNotificationForInfobip()
{
    return '+1' . $this->mobil;
}

Available Message methods

InfobipSmsMessage

  • content(''): 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 ricardo dot ramirez dot r at gmail dot you know 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

Infobip notifications channel for Laravel 5.4

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%