assaqqaf / zendesk-laravel-notification
Zendesk 通知驱动程序
v0.4.2
2017-01-17 12:28 UTC
Requires
- php: >=5.6.4
- illuminate/notifications: 5.3.*
- illuminate/support: 5.1.*|5.2.*|5.3.*
- zendesk/zendesk_api_client_php: ~2.0
Requires (Dev)
- mockery/mockery: ^0.9.5
- orchestra/testbench: 3.3.x-dev
- phpunit/phpunit: 4.*
This package is not auto-updated.
Last update: 2024-09-28 19:20:42 UTC
README
此包使得使用 Laravel 5.3 创建 Zendesk API 变得容易。
内容
安装
您可以通过 composer 安装此包。
composer require assaqqaf/zendesk-laravel-notification
将服务提供者添加到 config/app.php
// config/app.php 'providers' => [ ... NotificationChannels\Zendesk\ZendeskServiceProvider::class, ],
设置 Zendesk 服务
将您的 Zendesk REST API 密钥添加到 config/services.php
// config/services.php ... 'zendesk' => [ 'subdomin' => env('ZENDESK_API_SUBDOMIN'), 'username' => env('ZENDESK_API_USERNAME'), 'token' => env('ZENDESK_API_TOKEN'), ], ...
用法
现在您可以在通知中的 via()
方法中使用该频道。
use NotificationChannels\Zendesk\ZendeskChannel; use NotificationChannels\Zendesk\ZendeskMessage; use Illuminate\Notifications\Notification; class ProjectCreated extends Notification { public function via($notifiable) { return [ZendeskChannel::class]; } public function toZendesk($notifiable) { return (new ZendeskMessage('Test Zendesk Notification', 'This will be sent as ticket body')); } }
为了让您的通知知道您正在针对哪个用户,将 routeNotificationForZendesk
方法添加到您的 Notifiable 模型中。
此方法需要返回授权 Evernote 用户的访问令牌。
public function routeNotificationForZendesk() { return [ 'name' => $this->name, 'email' => $this->email, ]; }
可用的消息方法
subject('')
:接受字符串值作为 Zendesk 工单名称。description('')
:接受字符串值作为 Zendesk 工单描述。content('')
:接受字符串值作为 Zendesk 工单内容消息。from('', '')
:接受字符串值作为 Zendesk 工单请求者名称和电子邮件。type('')
:接受字符串值作为 Zendesk 工单类型。允许的值是 problem、incident、question 或 task。priority('')
:接受字符串值作为 Zendesk 工单优先级。允许的值是 urgent、high、normal 或 low。status('')
:接受字符串值作为 Zendesk 工单状态。允许的值是 new、open、pending、hold、solved 或 closed。visible()
:设置评论为公开。tags([])
:接受数组值作为 Zendesk 工单标签。customField($id, $value)
:设置新自定义字段。接受自定义字段 id 作为整数和字段值。group('')
:接受整数作为组 id,将工单分配到此组。ticket()
:接受整数作为工单 id。如果设置了工单 id,则通知将更新此工单。
事件
当工单创建或更新时,包会触发和事件。以下事件可用:
NotificationChannels\Zendesk\Events\ZendeskTicketWasCreated
NotificationChannels\Zendesk\Events\ZendeskTicketWasUpdated
变更日志
请参阅 CHANGELOG 了解最近更改的更多信息。
测试
$ composer test
贡献
请参阅 CONTRIBUTING 了解详细信息。
鸣谢
许可
MIT 许可证 (MIT)。请参阅 许可文件 了解更多信息。