innoflash/za-sms

An SMS package to handle SMS sending from South African providers

v1.0.6 2021-03-14 18:17 UTC

This package is auto-updated.

Last update: 2024-11-15 02:29:11 UTC


README

Software License Travis Total Downloads

Table of contents

Introduction

This package is aimed at creating a South African SMS package for for local SMS providers using their REST APIs. Below is a list of providers we currently integrated:

Install

composer require innoflash/za-sms

Usage

Once the package is installed you will need to set the provider in the .ENV file as follows:

ZA_SMS_PROVIDER={provider}

Available providers:

Use as a notification

za-sms supports being a driver for Laravel Notification

  • In the Notifiable class set your model phone number field by overriding this
    function routeNotificationForZasms($notification)
    {
        return $this->phone_number;
    }
  • In the Notification class use the za-sms as follows
    public function via($notifiable)
    {
        return [ZaSMSChannel::class];
    }
  • Then create the notification body as follows
    function toZaSMS($notifiable)
    {
        return (new ZaSMS)
            ->message('This is my message')  
            ->sendAt(now()->addDays(2)) // for scheduling messegaes 
            ->campaign('my campain'); //for message campaining
    }

Use as a Facade

At times you would want to send the SMS your own way so you can use the ZaSMS facade

    ZaSMS::setRecipientNumber('0651562779')
        ->setMessage('the facade message')
        ->sendMessage();

    //or

    ZaSMS::setMessageData([
        'recipientNumber' => '0027651562779',
        'message' => 'data message'
        ])->sendMessage();

Additionally

You can also access the SMS Provider object using all available service container methods

    $provider = app()->make('za-sms');
    $provider = app()->make(SMSProviderContract::class);

    $provider = resolve('za-sms');
    $provider = resolve(SMSProviderContract::class);

    //or use dependency injection

    function myFunction(SMSProviderContract $provider){
        //todo use the provider
    }

Contributing

Security

If you discover any security-related issues, please email innocentmazando@gmail.com instead of using the issue tracker.

License

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