w3-devmaster / laravel-notibot

laravel 框架的 API 包

1.0.0 2023-11-06 11:02 UTC

This package is auto-updated.

Last update: 2024-09-06 15:52:05 UTC


README

Latest Version Total Downloads

安装

使用 composer 安装

composer require w3-devmaster/laravel-notibot

发布包配置文件

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

将以下内容添加到 .env 文件中

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

基本使用

邮件警报(立即发送)

use W3Devmaster\Notibot\Sender\Email;

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

行通知(立即发送)

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;
}

高级使用(事务警报)

创建事务

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


public function create()
{
    $email = new Email();
    $email->to('to-email@domain.com')
        ->subject('test')
        ->sender('sender-email@domain.com')
        ->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;
}

获取所有事务

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

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

按 ID 查看事务

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

按 ID 更新事务

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


public function update($transactionId)
{
    $email = new Email();
    $email->to('to-email@domain.com')
        ->subject('test')
        ->sender('sender-email@domain.com')
        ->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;
}

按 ID 删除事务

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

获取发送日志

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

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

查看发送日志

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

变更日志

请参阅 CHANGELOG 了解最近更改的详细信息。