2017 © Pedro Peláez
 

library notific-php-sdk

An SDK to easily work with the Notific API

image

notific/notific-php-sdk

An SDK to easily work with the Notific API

  • Thursday, June 7, 2018
  • by palokankare
  • Repository
  • 2 Watchers
  • 5 Stars
  • 273 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 5 Versions
  • 23 % Grown

The README.md

Notific.io , (*1)

An SDK to easily work with the Notific API

This SDK lets you perform API calls to Notific. API documentation https://notific.io/api, (*2)

Usage

To install the SDK in your project you need to require the package via composer:, (*3)

$ composer require notific/notific-php-sdk, (*4)

Create an instance of the SDK:, (*5)

$notific = new Notific\PhpSdk\Notific(APP_ID, API_TOKEN);

If you don't have an App ID yet, sign up at https://app.notific.io/signup, (*6)

Public notifications

You can get an array of public notification instances with publicNotifications() method., (*7)

$notific->publicNotifications();

You can optionally give arguments to method which will be transformed to query parameters. Read more about filtering and sorting options from API documentation, (*8)

$notific->publicNotifications([
    'page' => 2,
    'limit' => 25,
    'sort' => '-created_at'
]);

Create new public notification., (*9)

$notific->createPublicNotification([
    'title' => 'Welcome!'
    'body'  => 'This is the body of the notification...'
]);

Retrieve a public notification instance., (*10)

$notification = $notific->publicNotification($id);

Update the notification., (*11)

$notification->update([
  'title' => 'Boom!'
  'body'  => 'This is the updated body of the notification.'
]);

Delete the notification., (*12)

$notification->delete();

Recipients

You can get an array of recipient instances with recipients() method., (*13)

$notific->recipients();

You can optionally give arguments to method which will be transformed to query parameters. Read more about filtering and sorting options from API documentation, (*14)

Create a recipient., (*15)

$notific->createRecipient([
    'id'    => '123', // Unique identifier for the user. You can use integers, hashes or what ever suites you best.
    'name'  => 'Kung Fury',
    'email' => 'kung.fury@email.com'
    'phone' => '+358 40 123 456' // You can add meta information to recipient as key => value pairs.
]);

Retrieve a recipient instance., (*16)

$recipient = $notific->recipient($id);

Update the recipient., (*17)

$recipient = $recipient->update([
    'name'  => 'Fury'
]);

Add tags to the recipient., (*18)

$recipient = $recipient->tag([
    'Foo', 'Bar', 'Baz'
]);

Remove tags from the recipient., (*19)

$recipient = $recipient->removeTags([
    'Bar'
]);

Remove all tags from the recipient., (*20)

$recipient = $recipient->removeAllTags();

Templates

Where private notifications are immutable and unnamed, templates are editable and easy to retrieve by name., (*21)

You can get an array of template instances with templates() method., (*22)

$notific->templates();

Create a template., (*23)

$notific->createTemplate([
    'title' => 'Lorem ipsum dolor sit amet.',
    'body'  => 'Lorem ipsum dolor sit amet, consectetur adipiscing...',
    'name' => 'lorem-ipsum'
]);

Retrieve a template with a name parameter., (*24)

$template = $notific->template($name);

Private notifications

You can get an array of private notification instances with privateNotifications() method., (*25)

$notific->privateNotifications();

You can optionally give arguments to method which will be transformed to query parameters. Read more about filtering and sorting options from API documentation, (*26)

$notific->privateNotifications([
    'filter[type]' => '1,2',
    'sort' => '-created_at'
]);

Create new private notification., (*27)

$notific->createPrivateNotification([
    'title' => 'Welcome!'
    'body'  => 'This is the body of the private notification...'
]);

Retrieve a private notification instance., (*28)

$notification = $notific->privateNotification($id);

Update the private notification., (*29)

$notification->update([
  'title' => 'Boom!'
  'body'  => 'This is the updated body of the private notification.'
]);

Send private notifications

You can use a private notification or a template to send a private notifications to recipient(s). We recommend you to use templates because they are easier to refer and manage as they are editable., (*30)

Send private notification with the notification id and recipient(s) id:s. Recipients can be a string, a list or an an array of id:s., (*31)

$data = $notific->template($name)->recipients($recipients)->send()
$data = $notific->privateNotification($notificationId)->recipients($recipients)->send()

You can use two delivery channels to send private notifications, broadcast (default) and email. Email channel requires valid email settings., (*32)

$data = $notific->template($name)->recipients($recipients)->channels('broadcast', 'email')->send()
$data = $notific->privateNotification($notificationId)->recipients($recipients)->channels('broadcast')->send()

If you are tagging your recipients you can send notification using tags. Tags can be a string, a list or an array of id:s. Recipient must have all given tags., (*33)

php $data = $notific->template($name)->tags($tags)->send(), (*34)

$data = $notific->privateNotification($notificationId)->tags($tags)->send()

To send a notification to ALL your recipients, use predefined tag all., (*35)

php $data = $notific->template($name)->tags('all')->send(), (*36)

$data = $notific->privateNotification($notificationId)->tags('all')->send()

Alternative way to send private notification with private notification instance., (*37)

$data = $notific->template($id)->sendTo($recipients);
$data = $notific->privateNotification($notificationId)->sendTo($recipients);

Send private notification with recipient instance., (*38)

$data = $notific->recipient($id)->sendNotification($notificationId);

Tip: you can test the private notification and send it to your self. You will receive the notification instantly if you are logged in to notific.io dashboard., (*39)

$data = $notific->template($name)->test();
$data = $notific->privateNotification($id)->test();

Pagination & limiting

Response data will be paginated to 15 items by default. Navigating through the pages and limiting the number of items per page can be done with query parameters. For example ?page=2&limit=25. Read more about paging and limiting from API documentation., (*40)

Security

If you discover any security related issues, please email kalle@klopal.com instead of using the issue tracker., (*41)

Credits

This package uses code from and is greatly inspired by the Oh Dear SDK package which is inspired by the Forge SDK package by Mohammed Said., (*42)

License

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

The Versions

07/06 2018

dev-master

9999999-dev https://github.com/notific/notific-php-sdk

An SDK to easily work with the Notific API

  Sources   Download

MIT

The Requires

 

The Development Requires

api php sdk notification notifications notific

10/04 2018

v1.0-beta.2

1.0.0.0-beta2 https://github.com/notific/notific-php-sdk

An SDK to easily work with the Notific API

  Sources   Download

MIT

The Requires

 

The Development Requires

api php sdk notification notifications notific

27/03 2018

v1.0-beta.1

1.0.0.0-beta1 https://github.com/notific/notific-php-sdk

An SDK to easily work with the Notific API

  Sources   Download

MIT

The Requires

 

The Development Requires

api php sdk notification notifications notific

01/03 2018

dev-analysis-q1Dg5v

dev-analysis-q1Dg5v https://github.com/notific/notific-php-sdk

An SDK to easily work with the Notific API

  Sources   Download

MIT

The Requires

 

The Development Requires

api php sdk notification notifications notific

26/02 2018

dev-analysis-q1DLxP

dev-analysis-q1DLxP https://github.com/notific/notific-php-sdk

An SDK to easily work with the Notific API

  Sources   Download

MIT

The Requires

 

The Development Requires

api php sdk notification notifications notific