w3-devmaster/laravel-notibot

API package for laravel framework

Downloads

2

Stars

0

Version

1.0.0

Notibot Services : API Package for any alert

Latest Version Total Downloads

Installation

Install with composer :

composer require w3-devmaster/laravel-notibot

Publish package config file :

php artisan vendor:publish --provider="W3Devmaster\Notibot\NotibotServiceProvider"

Add below to .env file :

ALERT_UUID=<your uuid from notibot services>
ALERT_TOKEN=<your secret token from notibot services>

Basic Use

Email Alert (send now) :

use W3Devmaster\Notibot\Sender\Email;

public function email()
{
    $email = new Email();
    $send = $email
        ->to('[email protected]')
        ->subject('test')
        ->sender('[email protected]')
        ->content([
            'title' => 'Email Title',
            'message' => 'Email Message',
            'footer' => 'Email Footer',
        ])
        ->exec();
    return $send;
}

Line notify (send now) :

use W3Devmaster\Notibot\Sender\LineNotify;

public function line() {
    $line = new LineNotify();

    $send = $line->to('<your line notify token>')
            ->message('test message')
            ->delay(true)
            ->delayTime('2023-11-10 15:00')
            ->exec();

    return $send;
}

Advanced Use (Transaction for alert)

Create transaction :

use W3Devmaster\Notibot\Notibot;
use W3Devmaster\Notibot\Sender\Email;
use W3Devmaster\Notibot\Sender\LineNotify;


public function create()
{
    $email = new Email();
    $email->to('[email protected]')
        ->subject('test')
        ->sender('[email protected]')
        ->content([
            'title' => 'Email Title',
            'message' => 'Email Message',
            'footer' => 'Email Footer',
        ]);

    $line = new LineNotify();

    $line->to('<your line notify token>')
        ->message('test message');

    $tranx = [
        'type' => 'onetime', // onetime | repeat
        'start' => '2023-11-10 15:00',
        'end' => '2023-11-10 15:00', // requried if type = repeat
        'next' => 2, // minute | requried if type = repeat
    ];

    $notibot = Notibot::create($tranx,$email,$line);

    return $notibot;
}

Get all transaction :

$notibot = new Notibot();
// Get all
$transactions = $notibot->transactions();

// Pages seperate
$transactions = $notibot->transactions($perPage,$page);

View transaction by id :

$notibot = new Notibot();
// Get id from other transaction : response->data
$transaction = $notibot->transaction($transactionId); 

Update transaction by id :

use W3Devmaster\Notibot\Notibot;
use W3Devmaster\Notibot\Sender\Email;
use W3Devmaster\Notibot\Sender\LineNotify;


public function update($transactionId)
{
    $email = new Email();
    $email->to('[email protected]')
        ->subject('test')
        ->sender('[email protected]')
        ->content([
            'title' => 'Email Title',
            'message' => 'Email Message',
            'footer' => 'Email Footer',
        ]);

    $line = new LineNotify();
    $line->to('<your line notify token>')
        ->message('test message');

    $tranx = [
        'type' => 'onetime', // onetime | repeat
        'start' => '2023-11-10 15:00',
        'end' => '2023-11-10 15:00', // requried if type = repeat
        'next' => 2, // minute | requried if type = repeat
    ];

    $notibot = Notibot::update($transactionId,$tranx,$email,$line); 

    return $notibot;
}

Delete transaction by id :

$notibot = new Notibot();
// Get id from other transaction : response->data
$notibot->delete($transactionId);

Get send logs :

$notibot = new Notibot();
// Get all logs
$logs = $notibot->logs();

// Pages seperate
$logs = $notibot->logs($perPage,$page);

View send logs :

$notibot = new Notibot();
// Log id from send logs
$logs = $notibot->log($logsId);

Changelog

Please see CHANGELOG for more information what has changed recently.

w3-devmaster

Author

w3-devmaster