digitalequation / teamwork
Requires
- php: ^7.4
- ext-json: *
- guzzlehttp/guzzle: ^7.0
- illuminate/support: ^8.3
Requires (Dev)
- orchestra/testbench: ^6.0
- phpunit/phpunit: ^9.3
- thebugsoftware/php-dump: ^1.0
This package is auto-updated.
Last update: 2023-11-18 15:09:47 UTC
README
这是一个 PHP Laravel 的 Teamwork Desk、Teamwork Help Docs 和 Teamwork Tickets API 封装库。
这个包是为我们的内部项目构建的,可能不适合您,但如果您喜欢,您可以自由使用它。
安装
您可以通过 composer 安装此包
composer require digitalequation/teamwork
运行包安装命令
php artisan teamwork:install
这将发布并注册 TeamworkServiceProvider,并生成一个配置文件 config/teamwork.php。
return [ 'desk' => [ /* |-------------------------------------------------------------------------- | Teamwork Desk Key |-------------------------------------------------------------------------- | | The Teamwork Desk API Key can be generated at: | https://your-domain.teamwork.com/desk/#myprofile/apikeys | */ 'key' => env('TEAMWORK_DESK_KEY'), /* |-------------------------------------------------------------------------- | Teamwork Desk Domain Name |-------------------------------------------------------------------------- | | The domain is the site address you have set on the Teamwork account. | To find the domain name just login to http://teamwork.com. | Then you will see the browser URL changing to: | https://your-domain.teamwork.com/launchpad/welcome | */ 'domain' => env('TEAMWORK_DESK_DOMAIN'), ], ];
您可以直接编辑此文件,但我们建议在 .env 文件中添加您的设置。
如果您编辑了配置文件并希望恢复默认设置,请运行
php artisan teamwork:publish
将您的 Teamwork Desk API 密钥和域名添加到 .env 文件
TEAMWORK_DESK_KEY=--YOUR-TEAMWORK-DESK-KEY-- TEAMWORK_DESK_DOMAIN=--YOUR-TEAMWORK-DESK-DOMAIN--
使用方法
使用 facade 的示例
use Teamwork; $response = Teamwork::desk()->me();
使用 依赖注入 的示例
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use DigitalEquation\Teamwork\Teamwork; class TeamworkController extends Controller { protected $teamwork; public function __construct(Teamwork $teamwork) { $this->teamwork = $teamwork; } public function getMe() { try { $response = $this->teamwork->desk()->me(); // do something with the response data... } catch (\Exception $e) { // do something with the error... } } // other methods
以下所有示例都将使用 Teamwork facade。
Teamwork Desk
获取当前用户数据
$response = Teamwork::desk()->me();
获取所有 Teamwork Desk 收件箱
$response = Teamwork::desk()->inboxes();
按名称获取收件箱
$response = Teamwork::desk()->inbox('Inbox Name');
上传文件
$teamworkUser = Teamwork::desk()->me(); $response = Teamwork::desk()->upload($teamworkUser['id'], $request->file);
文件上传的示例响应
[
'id' => 1312, // the uploaded file id on Teamwork
'url' => 'http://...', // the URL of the image
'extension' => 'jpg',
'name' => 'Some File Name',
'size' => '42342', // the image size in kb
]
提示:将您的 Teamwork 调用放在 try-catch 块中,以捕获可能抛出的任何异常。
Teamwork Tickets
获取票务优先级
$response = Teamwork::tickets()->priorities();
按 ID 获取票务
$response = Teamwork::tickets()->ticket($ticketId);
获取客户/用户的票务列表
$response = Teamwork::tickets()->customer($customerId);
发布/发送票务
$data = [ 'assignedTo' => 5465, // the id of the assigned user on ticket 'inboxId' => 5545, // the inbox id where the ticket will be sent 'tags' => 'Test ticket', 'priority' => 'low', 'status' => 'active', 'source' => 'Email (Manual)', 'customerFirstName' => 'Test', // sender's first name 'customerLastName' => 'User', // sender's last name 'customerEmail' => 'test.user@email.com', // sender's email 'customerPhoneNumber' => '', // sender's phone number 'subject' => 'Ticket Subject', 'previewTest' => 'Ticket excerpt.', 'message' => 'The ticket body...', ]; $response = Teamwork::tickets()->post($data);
回复票务
$data = [ 'ticketId' => 2201568, // the ticket id where the reply will be sent 'body' => 'Reply TEST on ticket.', 'customerId' => 65465, ]; $response = Teamwork::tickets()->reply($data);
Teamwork Help Docs
获取站点列表
$response = Teamwork::helpDesk()->getSites();
按 ID 获取 Help Docs 站点
$response = Teamwork::helpDesk()->getSite($siteId);
获取站点内的所有分类
$response = Teamwork::helpDesk()->getSitesCategories($siteId);
获取分类内的文章
$response = Teamwork::helpDesk()->getCategoryArticles($categoryId, $pageId);
获取站点文章列表
$response = Teamwork::helpDesk()->getSiteArticles($siteId, $pageId);
获取单个文章
$response = Teamwork::helpDesk()->getArticle($articleId);
按 ID 获取多个文章
$response = Teamwork::helpDesk()->getArticles($articleIDs);
测试
composer test
这将生成一个覆盖率报告,可在 build 目录下访问,并打开 index.html 文件查看结果。
变更日志
有关最近更改的更多信息,请参阅CHANGELOG。
贡献
有关详细信息,请参阅CONTRIBUTING。
安全性
如果您发现任何安全相关的问题,请通过电子邮件robert@thebug.ro联系,而不是使用问题跟踪器。
致谢
许可证
MIT 许可证(MIT)。有关更多信息,请参阅许可证文件。