2017 © Pedro Peláez
 

library api-x

An unofficial laravel package for SmartSMSSolutions' APIx. The Package that helps deliver SMS to phone numbers on Do Not Disturb (DND).

image

abdulmatinsanni/api-x

An unofficial laravel package for SmartSMSSolutions' APIx. The Package that helps deliver SMS to phone numbers on Do Not Disturb (DND).

  • Wednesday, June 6, 2018
  • by abdulmatinsanni
  • Repository
  • 0 Watchers
  • 0 Stars
  • 5 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 400 % Grown

The README.md

api-x

Latest Version on Packagist ![Software License][ico-license] ![Total Downloads][ico-downloads], (*1)

An unofficial laravel package for SmartSMSSolutions' API-x. The Package that helps deliver SMS to phone numbers on Do Not Disturb (DND)., (*2)

Structure

Below is the file structure of this package., (*3)

\---src
    |   APIx.php
    |   APIxMessage.php
    |   APIxServiceProvider.php
    |
    +---Channels
    |       SmartSMSChannel.php
    |
    +---Commands
    |   \---Log
    |           ClearCommand.php
    |           DisplayCommand.php
    |
    +---config
    |       api-x.php
    |
    +---Controllers
    |       LogController.php
    |
    +---Exceptions
    |       CouldNotSendNotification.php
    |       InvalidConfiguration.php
    |
    +---Facades
    |       APIxFacade.php
    |
    \---resources
        \---views
                log.blade.php

Install

You can install the package via composer:, (*4)

``` bash $ composer require abdulmatinsanni/api-x, (*5)


Add the service provider (only required on Laravel 5.4 or lower): ``` php // config/app.php 'providers' => [ ... AbdulmatinSanni\APIx\APIxServiceProvider::class, ], 'aliases' => [ 'APIx' => AbdulmatinSanni\APIx\Facades\APIxFacade::class, ],

Setting up your API-x account

Add your API-x API Token (string), Log Message (boolean), Mock SMS (boolean) and Sender Name (optional|string) to your .env (environment) file: ```$xslt SMARTSMSSOLUTIONS_API_TOKEN=apixtokenhere SMARTSMSSOLUTIONS_LOG_MESSAGES=true SMARTSMSSOLUTIONS_FAKE_SMS=true SMARTSMSSOLUTIONS_SENDER_NAME=sendernamehere, (*6)


## Usage ### In Controllers: Below is an example of API-x usage in controllers. ``` php ... use APIx; class SMSController extends Controller { public function send(Request $request) { $response = APIx::to($request->recipient) ->from($request->name) ->message($request->message) ->send(); return $response; } }

For Notifications:

Setting up in model:

...

class User extends Model
{
    use Notifiable;

    public function routeNotificationForSmartSMS($notification)
    {
        return $this->phone_column;
    }
}

Setting up in notifications


... use AbdulmatinSanni\APIx\APIxMessage; use AbdulmatinSanni\APIx\Channels\SmartSMSChannel; class DemoNotification extends Notification { use Queueable; ... public function via($notifiable) { return [SmartSMSChannel::class]; } ... public function toSmartSMS($notifiable) { return (new APIxMessage()) ->from($this->from) ->message($this->message); } }

Setting up in controllers


... public class NotificationsController extends Controller { public function notify() { $user = User::firstOrFail(); $user->notify(new DemoNotification("SarahFound", "Hi, you are invited to our seminar!!!!!")); } }

Available message methods

  • to([]): Accepts an array or string of recipients' phone number(s).
  • from(''): Accepts a phone to use as the sms sender.
  • message(''): Accepts a string value for the sms body.
  • send(): Does the sending of the sms. Can also accept a string which represent sms body if message('') was skipped.

Command line

Showing all entries of log: ``` bash $ php artisan api-x:log, (*7)


Showing the last logged sms: ``` bash $ php artisan api-x:log --latest

Limiting the entries of log to be displayed: ``` bash $ php artisan api-x:log --limit={no_of_messages}, (*8)

Clearing all entries of log:
``` bash
$ php artisan api-x:log clear

Change log

Please see CHANGELOG for more information on what has changed recently., (*9)

Testing

bash $ composer test (NOT YET), (*10)

Contributing

Please see CONTRIBUTING and CODE_OF_CONDUCT for details., (*11)

Security

If you discover any security related issues, please email me@abdulmatinsanni.com instead of using the issue tracker., (*12)

Credits

License

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

The Versions

06/06 2018

1.1.1

1.1.1.0 https://github.com/AbdulmatinSanni/APIx

An unofficial laravel package for SmartSMSSolutions' APIx. The Package that helps deliver SMS to phone numbers on Do Not Disturb (DND).

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel sms apix abdulmatinsanni

06/06 2018

dev-master

9999999-dev https://github.com/AbdulmatinSanni/APIx

An unofficial laravel package for SmartSMSSolutions' APIx. The Package that helps deliver SMS to phone numbers on Do Not Disturb (DND).

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel sms apix abdulmatinsanni

06/06 2018

1.1.0

1.1.0.0 https://github.com/AbdulmatinSanni/APIx

An unofficial laravel package for SmartSMSSolutions' APIx. The Package that helps deliver SMS to phone numbers on Do Not Disturb (DND).

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel sms apix abdulmatinsanni