badchoice / handesk-php
Handesk PHP sdk
1.1.1
2021-07-22 07:31 UTC
Requires
- illuminate/http: ^7.0
- nesbot/carbon: ^2.0.0
Requires (Dev)
- fzaninotto/faker: ~1.4
- mockery/mockery: 0.9.*
- phpunit/phpunit: ~5.7
README
Handesk PHP sdk
查看完整项目:https://github.com/BadChoice/handesk
安装
composer require badchoice/handesk-php
用法
初始化
要初始化 Handesk-php sdk,只需调用
Handesk::setup('your-handesk-url', 'your-handesk-api-token');
如果你使用 Laravel,可以使用 config/services.php
文件,并按照以下方式操作
// In AppServiceProvider boot method Handesk::setup(config('services.handesk.url'), config('services.handesk.token'));
//In config.services.php file 'handesk' => [ 'url' => env('HANDESK_URL', 'http://handesk.dev/api'), 'token' => env('HANDESK_TOKEN', 'the-api-token') ],
工单
要获取请求者的开放工单(只返回工单标题,详见下面的 find 以获取完整工单)
$tickets = (new Ticket)->get('requesterNameOrEmail');
你可以通过添加第二个参数来获取已关闭或已解决的工单
$solvedTickets = (new Ticket)->get('requesterNameOrEmail','solved'); $openTickets = (new Ticket)->get('requesterNameOrEmail','solved');
你也可以创建新的工单
$ticket_id = (new Ticket)->create( ["name" => "Requester name", "email" => "requester@email.com"], "The ticket subject", "The ticket initial body", ["tag1","tag2"] );
然后获取工单
$ticket = (new Ticket)->find($id); $comments = $ticket->comments; //Includes the initial comment $comments->first()->requester; // ["name" => "Requester name", "email" => "Requester email"]
为工单添加评论
$ticket->addComment("Adding a comment"); $ticket->addComment("Adding a comment and solving the ticket", true);
团队
$team = Team::create("team name", "team email"; (new Team(2))->tickets(); //gets all open tickets for team with id 2 (new Team(2))->tickets('solved'); //gets all solved tickets for team with id 2 (new Team(2))->ticketsCount(); //gets the count of all open tickets for team with id 2 (new Team(2))->ticketsCount('closed'); //gets the count of all closed tickets for team with id 2 (new Team(2))->leads(); //gets the open leads for a team (paginated) (new Team(2))->leadsCount(); //gets the count of all live leads for team with id 2
领导
要创建一个领导,只需调用
$id = (new Lead)->create([ "email" => "bruce@wayne.com", "body" => "I'm interested in buying this awesome app", "username" => "brucewayne", "name" => "Bruce Wayne", "phone" => "0044 456 567 54", "address" => "Wayne manner", "city" => "Gotham", "postal_code" => "90872", "company" => "Wayne enterprises"] , ["lightning","handesk"] );
只有
name
是必填字段
开发
欢迎提交 PR