forked from AaronDDM/Kayako-REST-API-Client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkyStaffGroup.php
120 lines (104 loc) · 3.32 KB
/
kyStaffGroup.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
<?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 StaffGroup object.
*
* @link http://wiki.kayako.com/display/DEV/REST+-+StaffGroup
* @author Tomasz Sawicki (https://github.com/Furgas)
*/
class kyStaffGroup extends kyObjectBase {
static protected $controller = '/Base/StaffGroup';
static protected $object_xml_name = 'staffgroup';
private $id = null;
private $title = null;
private $is_admin = false;
protected function parseData($data) {
$this->id = intval($data['id']);
$this->title = $data['title'];
$this->is_admin = intval($data['isadmin']) === 0 ? false : true;
}
protected function buildData($method) {
$data = array();
//TODO: check if required parameters are present
$data['title'] = $this->title;
$data['isadmin'] = $this->is_admin ? 1 : 0;
return $data;
}
public function toString() {
return sprintf("%s (isadmin: %s)", $this->getTitle(), $this->getIsAdmin() ? "yes" : "no");
}
public function getId($complete = false) {
return $complete ? array($this->id) : $this->id;
}
/**
* Returns title of the staff group.
*
* @return string
* @filterBy()
* @orderBy()
*/
public function getTitle() {
return $this->title;
}
/**
* Sets title of the staff group.
*
* @param string $title Title of the staff group.
* @return kyStaffGroup
*/
public function setTitle($title) {
$this->title = $title;
return $this;
}
/**
* Returns whether staff members assigned to this group are Administrators.
*
* @return bool
* @filterBy()
* @orderBy()
*/
public function getIsAdmin() {
return $this->is_admin;
}
/**
* Sets whether staff members assigned to this group are Administrators.
*
* @param bool $is_admin True, if you want staff members assigned to this group to be Administrators. False (default), otherwise.
* @return kyStaffGroup
*/
public function setIsAdmin($is_admin) {
$this->is_admin = $is_admin;
return $this;
}
/**
* Creates new staff group.
* WARNING: Data is not sent to Kayako unless you explicitly call create() on this method's result.
*
* @param string $title Title of new staff group.
* @param bool $is_admin True, if you want staff members assigned to this group to be Administrators. False (default), otherwise.
* @return kyStaffGroup
*/
static public function createNew($title, $is_admin = false) {
$new_staff_group = new kyStaffGroup();
$new_staff_group->setTitle($title);
$new_staff_group->setIsAdmin($is_admin);
return $new_staff_group;
}
/**
* Creates new staff user in this staff group.
* WARNING: Data is not sent to Kayako unless you explicitly call create() on this method's result.
*
* @param string $first_name First name of new staff user.
* @param string $last_name Last name of new staff user.
* @param string $user_name Login username of new staff user.
* @param string $email E-mail address of new staff user.
* @param string $password Password for new staff user.
* @return kyStaff
*/
public function newStaff($first_name, $last_name, $user_name, $email, $password) {
return kyStaff::createNew($first_name, $last_name, $user_name, $email, $this, $password);
}
}