businessprocess/notify-service 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

businessprocess/notify-service

Composer 安装命令:

composer require businessprocess/notify-service

包简介

Package for notification channels

README 文档

README

PHP 8.x Laravel 8.x Yii 2.x Latest Stable Version Release date Release Version Total Downloads Pull requests Software License Stars

Notification messenger channel to Laravel FrameWork v6.0 and above.

Installation

The recommended way to install channel is through Composer.

composer require businessprocess/notify-service

Usage

    Notify::getDeliveryProfiles() - Get all delivery profiles
    Notify::notifications() - get all notification
namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Notification;

class MyNotification extends Notification implements ShouldQueue
{    
   public function via($notifiable): array
    {
        return ['notify'];
    }

    public function toNotify($notifiable)
    {    
        $notice = \NotificationChannels\Models\NotifyService\Notice::create('profileUuid');
        
        $notice->setLangCode(app()->getLocale())
            ->setTimeToDelivery(now()->addHour())
            ->setText('Welcome to hell')
            ->options()
            ->email(
            'Hello email',
            'From admin'
        );
            
        $notice->destination()
            ->email($notifiable->email)
            ->viber($notifiable->phone);    
            
        //add file to notice
        $notice->setFile(storage_path('./random.jpg'))
            
        $notice->responseCallback(function (?array $response){
            // can be processed response from notify service
            if(! is_null($response)){
                echo data_get($response, 'id');
            }
        })
        
        return $notice;     
    }
}
    // Notice object can be obtained from the container with the addition of the profileUuid from the configuration
    
    public function toNotify($notifiable, \NotificationChannels\Models\NotifyService\Notice $notice)
    {
        return $notice->fill('ArrayOfParams');
    }
}
    //call
    $user->notify(new MyNotification());
    
    //or multiply users
    
    Notification::send($users, new MyNotification());

Available Options

Option Description Default value
url API url (required) null
login Login (required) null
password Password (required) null
profileUuid Uuid of delivery profile null

Params Heroku/BptPaymentsBot/SmartSender

Option Description Default value
profileUuid Uuid of delivery profile (required) null
langCode Notify template locale (required) null
emitter Group by string key null
destination Recipient channel keys (required) null,object
data Template data (required if no text) null,object
text Message text (required if no data) null
options Options null,object
key Group by key null
timeToDelivery Time to delivery null
   public function via($notifiable): array
    {
        return ['messenger'];
    }

    public function toMessenger($notifiable): string
    {
        return 'Text of body';
    }

Available Options

Option Description Default value
authentication Your API key (required) null
url API url (required) null
project_id Project iD (required) null
messenger List of messengers (required) viber
sendAll Send to all messenger in list false
callback_url Callback url to response from messenger null
user_phone User phone null
   public function via($notifiable): array
    {
        return ['smart-sender'];
    }

    public function toSmartSender($notifiable): AbstractSender
    {
        return new BptPaymentsBot::task(         
            'ArrayOfParams'       
        );
    }

Available Options

Option Description Default value
url API url (required) null

Params Heroku/BptPaymentsBot/SmartSender

Option Description Default value
requestID Your request ID (required) null
date Date by format Y-m-d H:i:s (required) null
type Request type (required) null
notes Comment (required) null
user User name (required) null
author Author name (required) null
amount Amount (required) null
applyUrl Callback approve url (required) null
declineUrl Callback cancel url (required) null

Usage Laravel

    $user = User::find(1);
    Notification::send($user, new EmailNotification)

Usage YII2

[
   'modules' => [
       'notifications' => [
           'class' => 'NotificationChannels\yii\Module',
               'channels' => [
                   'notify' => [
                       'class' => 'NotificationChannels\yii\Channels\NotifyChannel',
                       'url' => $params['notifyService']['url'],
                       'login' => $params['notifyService']['login'],
                       'password' => $params['notifyService']['password'],
                   ],            
               ],
           ],
       ],
   ],
]
namespace app\notifications;

use NotificationChannels\yii\Notification;
use NotificationChannels\Models\NotifyService\Notice;

class EmailNotification extends Notification
{
   public function via($notifiable): array
   {
       return ['notify'];
   } 
   
   public function toNotify($notifiable)
   {
       return Notice::create(
        'ArrayOfParams' 
       );
   }
}
   $user = User::findOne(1);
   
   EmailNotification::create()->sendTo($user);
   // (new EmailNotification())->sendTo($user);

businessprocess/notify-service 适用场景与选型建议

businessprocess/notify-service 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5.84k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2023 年 04 月 19 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 businessprocess/notify-service 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 businessprocess/notify-service 我们能提供哪些服务?
定制开发 / 二次开发

基于 businessprocess/notify-service 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 5.84k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 6
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-04-19