forked from AaronDDM/Kayako-REST-API-Client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkyTicketType.php
143 lines (126 loc) · 3.05 KB
/
kyTicketType.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<?php
require_once('kyObjectBase.php');
/**
* Part of PHP client to REST API of Kayako v4 (Kayako Fusion).
* Compatible with Kayako version >= 4.01.204.
*
* Kayako TicketType object.
*
* @author Tomasz Sawicki (https://github.com/Furgas)
*/
class kyTicketType extends kyObjectBase {
const TYPE_PUBLIC = 'public';
const TYPE_PRIVATE = 'private';
static protected $controller = '/Tickets/TicketType';
static protected $object_xml_name = 'tickettype';
protected $read_only = true;
private $id = null;
private $title = null;
private $display_order = null;
private $department_id = null;
private $display_icon = null;
private $type = null;
private $user_visibility_custom = null;
private $user_group_ids = array();
protected function parseData($data) {
$this->id = intval($data['id']);
$this->title = $data['title'];
$this->display_order = intval($data['displayorder']);
$this->department_id = intval($data['departmentid']);
$this->display_icon = $data['displayicon'];
$this->type = $data['type'];
$this->user_visibility_custom = intval($data['uservisibilitycustom']) === 0 ? false : true;
if ($this->user_visibility_custom && is_array($data['usergroupid'])) {
foreach ($data['usergroupid'] as $user_group_id) {
$this->user_group_ids[] = intval($user_group_id);
}
}
}
public function toString() {
return sprintf("%s (type: %s)", $this->getTitle(), $this->getType());
}
public function getId($complete = false) {
return $complete ? array($this->id) : $this->id;
}
/**
*
* @return string
* @filterBy()
* @orderBy()
*/
public function getTitle() {
return $this->title;
}
/**
*
* @return int
* @filterBy()
* @orderBy()
*/
public function getDisplayOrder() {
return $this->display_order;
}
/**
*
* @return int
* @filterBy()
*/
public function getDepartmentId() {
return $this->department_id;
}
/**
*
* @todo Cache the result in object private field.
* @return kyDepartment
*/
public function getDepartment() {
if ($this->department_id === null || $this->department_id <= 0)
return null;
return kyDepartment::get($this->department_id);
}
/**
*
* @return string
*/
public function getDisplayIcon() {
return $this->display_icon;
}
/**
*
* @return string
* @filterBy()
* @orderBy()
*/
public function getType() {
return $this->type;
}
/**
*
* @return bool
* @filterBy()
*/
public function getUserVisibilityCustom() {
return $this->user_visibility_custom;
}
/**
*
* @return int[]
* @filterBy(UserGroupId)
* @orderBy(UserGroupId)
*/
public function getUserGroupIds() {
return $this->user_group_ids;
}
/**
*
* @todo Cache the result in object private field.
* @return kyResultSet
*/
public function getUserGroups() {
$user_groups = array();
foreach ($this->user_group_ids as $user_group_id) {
$user_groups[] = kyUserGroup::get($user_group_id);
}
return new kyResultSet($user_groups);
}
}