atech/sirportly

使用PHP与Sirportly数据进行交互。

dev-master 2018-10-01 14:23 UTC

This package is not auto-updated.

Last update: 2024-09-28 15:59:56 UTC


README

此库允许您使用PHP与Sirportly数据进行交互。

设置Sirportly客户端

$sirportly = new Sirportly('the-token','the-secret');

创建工单

您可以在Sirportly系统中使用几个命令创建工单。请注意,创建新的工单是一个两步过程 - 首先,您需要创建一个Ticket记录,然后您需要使用新创建的工单上的post_update来发布您的初始更新。

# Create the skeleton ticket
$properties = array(
    'brand' => 'Sirportly', 
    'department' => 'Sales Enquiries',
    'status' => 'New',
    'priority' => 'Normal',
    'subject' => 'A new sales enquiry',
    'name' => 'My New Customer',
    'email' => 'customer@atechmedia.com',
    );
    
  $ticket = $sirportly->create_ticket($properties);

# Now add the first update to this ticket
$update = $sirportly->post_update(array('ticket' => $ticket['reference'], 'message' => 'I would like some more info about your product', 'customer' => $ticket['customer']['id'] ));

如果发生错误,您将收到一个错误数组。还有许多其他属性可以传递给create_ticket方法,但在此未进行文档说明。请参阅API文档以获取有关可用选项的更多信息。

访问工单

$sirportly->tickets();                   
$sirportly->ticket(array('reference' => 'AB-123123'));      

更改工单属性

如果您想更改工单的属性,可以使用update_ticket。此函数的行为与相应的API方法完全相同,更多详细信息请参阅文档

# Change a ticket status
$sirportly->update_ticket(array('ticket' => 'GI-857090', 'status' => 'waiting for staff'));

# Change a ticket priority
$sirportly->update_ticket(array('ticket' => 'GI-857090', 'priority' => 'low'));

# Change multiple attributes
$sirportly->update_ticket(array('ticket' => 'GI-857090', 'team' => '1st line support', 'user => 'dave'));

更新完成后,原始工单对象将被更新以包含新属性。

发布工单更新

发布工单更新是一个简单的过程,post_update函数将接受文档中定义的相同参数。

# To post a system message without a user
$sirportly->post_update(array('ticket' => 'GI-857090', 'message' => 'My Example Message' ));

# To post an update as the ticket customer
$sirportly->post_update(array('ticket' => 'GI-857090', 'message' => 'My Example Message', 'customer' => 'Daniel' ));

# To post an update as a user
$sirportly->post_update(array('ticket' => 'GI-857090', 'message' => 'My Example Message', :user => 'Daniel')

# To post a private update as a user
$sirportly->post_update(array('ticket' => 'GI-857090', 'message' => 'Private Msg', 'user' => 'Daniel', 'private' => true ));

执行宏

如果您想在工单上执行宏,可以使用接受要执行宏的ID或名称的run_macro函数。如果执行成功,它将返回true,并更新原始工单属性。

$sirportly->run_macro( array('ticket' => 'GI-857090', 'macro' => 'Mark as waiting for staff') );

添加跟进

可以通过执行add_follow_up函数来向工单添加跟进。

$sirportly->add_follow_up( array('ticket' => 'GI-857090', 'actor' => 'Daniel', 'status' => 'resolved', 'run_at' => 'yyyy-mm-dd hh-mm') );

run_at属性应是我们API文档中日期/时间格式化页面上概述的戳记。

创建用户

您可以通过API创建用户(员工)。

$user_properties = array(
    'first_name' => 'John', 
    'first_name' => 'Particle', 
    'email_address' => 'john@testcompany.com', 
    'admin_access' => true, 
    );

$sirportly->create_user($user_properties);

还有其他可用的属性,您可以在API文档中查看。

您不需要创建单个客户。这些将在工单和工单更新创建时自动创建。

访问静态数据对象

Sirportly API提供了访问您Sirportly数据库中存储的所有数据对象的权限。目前,这些数据无法通过API进行编辑。

$sirportly->statuses();
$sirportly->priorities();
$sirportly->brands();
$sirportly->users();

您可以使用此方法访问以下对象:品牌、部门、升级路径、过滤器、优先级、SLA、状态、联系人、团队和用户。

执行SPQL查询

Sirportly包括一个名为SPQL(SirPortly查询语言)的强大查询语言,它允许您通过API查询您的工单数据。这主要用于生成报告,但也可用于返回您自己的数据。

$sirportly->spql(array('spql' => 'SELECT COUNT, status.name FROM tickets GROUP BY status.

访问知识库列表

您可以通过调用

$sirportly->kb_list()

访问单个知识库

您可以通过使用以下方法访问单个知识库的完整页面树

$sirportly->kb($kb_id = 1234);