forked from Furgas/php-api-library
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkyTroubleshooterComment.php
More file actions
130 lines (114 loc) · 3.72 KB
/
kyTroubleshooterComment.php
File metadata and controls
130 lines (114 loc) · 3.72 KB
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
<?php
/**
* Kayako TroubleshooterComment object.
*
* @author Saloni Dhall (https://github.com/SaloniDhall)
* @link http://wiki.kayako.com/display/DEV/REST+-+TroubleshooterComment
* @since Kayako version 4.64.1
* @package Object\TroubleshooterComment
*
*/
class kyTroubleshooterComment extends kyCommentBase {
static protected $controller = '/Troubleshooter/Comment';
static protected $object_xml_name = 'troubleshooterstepcomment';
/**
* Troubleshooterstep item identifier.
* @apiField required_create=true
* @var int
*/
protected $troubleshooterstep_item_id;
/**
* Troubleshooterstep item.
* @var kyTroubleshooterstep
*/
protected $troubleshooterstep_item;
protected function parseData($data) {
parent::parseData($data);
$this->troubleshooterstep_item_id = ky_assure_positive_int($data['troubleshooterstepid']);
}
public function buildData($create) {
$data = parent::buildData($create);
$this->buildDataNumeric($data, 'troubleshooterstepid', $this->troubleshooterstep_item_id);
return $data;
}
/**
* Returns all the troubleshooter step identifiers.
*
* @param array $troubleshooterstep
*
* @return kyResultSet
*/
static public function getAll($troubleshooterstep) {
if ($troubleshooterstep instanceof kyTroubleshooterStep) {
$troubleshooterstep_item_id = $troubleshooterstep->getId();
} else {
$troubleshooterstep_item_id = $troubleshooterstep;
}
return parent::getAll(array('ListAll', $troubleshooterstep_item_id));
}
/**
* Return troubleshooter item identifier.
*
* @return int
* @filterBy
* @orderBy
*/
public function getTroubelshooterStepId() {
return $this->troubleshooterstep_item_id;
}
/**
* Sets the troubleshooterstep Id.
*
* @param int $troubleshooterstep_item_id TroubleshooterStep identifier
*
* @return $this
*/
public function setTroubelshooterStepId($troubleshooterstep_item_id) {
$this->troubleshooterstep_item_id = ky_assure_positive_int($troubleshooterstep_item_id);
$this->troubleshooterstep_item = null;
return $this;
}
/**
* Return troubleshooter item.
*
* Result is cached until the end of script.
*
* @param bool $reload True to reload data from server. False to use the cached value (if present).
* @return kyTroubleshooterStep
*/
public function getTroubleshooterStep($reload = false) {
if ($this->troubleshooterstep_item !== null && !$reload)
return $this->troubleshooterstep_item;
if ($this->troubleshooterstep_item_id === null)
return null;
$this->troubleshooterstep_item = kyTroubleshooterStep::get($this->troubleshooterstep_item_id);
return $this->troubleshooterstep_item;
}
/**
* Sets the troubleshooterstep item
*
* @param int $troubleshooterstep_item
*
* @return $this
*/
public function setTroubleshooterStep($troubleshooterstep_item) {
$this->troubleshooterstep_item = ky_assure_object($troubleshooterstep_item, 'kyTroubleshooterStep');
$this->troubleshooterstep_item_id = $this->troubleshooterstep_item !== null ? $this->troubleshooterstep_item->getId() : null;
return $this;
}
/**
* Creates a new troubelshooterstep comment.
* WARNING: Data is not sent to Kayako unless you explicitly call create() on this method's result.
*
* @param kyTroubleshooterStep $troubleshooterstep TroubleshooterStep item.
* @param kyUser|kyStaff|string $creator Creator (staff object, user object or user fullname) of this comment.
* @param string $contents Contents of this comment.
* @return kyTroubleshooterComment
*/
static public function createNew($troubleshooterstep, $creator, $contents) {
/** @var $new_comment kyTroubleshooterComment */
$new_comment = parent::createNew($creator, $contents);
$new_comment->setTroubleshooterStep($troubleshooterstep);
return $new_comment;
}
}