1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace allejo\DaPulse; |
4
|
|
|
|
5
|
|
|
use allejo\DaPulse\Objects\ApiObject; |
6
|
|
|
|
7
|
|
|
class PulseNote extends ApiObject |
|
|
|
|
8
|
|
|
{ |
9
|
|
|
const API_PREFIX = "pulses"; |
10
|
|
|
|
11
|
|
|
// ================================================================================================================ |
12
|
|
|
// Instance Variables |
13
|
|
|
// ================================================================================================================ |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* The collaboration box type (rich_text, file_list, faq_list). |
17
|
|
|
* |
18
|
|
|
* @var string |
19
|
|
|
*/ |
20
|
|
|
protected $type; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* The note's id. |
24
|
|
|
* |
25
|
|
|
* @var string |
26
|
|
|
*/ |
27
|
|
|
protected $id; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* The note's title. |
31
|
|
|
* |
32
|
|
|
* @var string |
33
|
|
|
*/ |
34
|
|
|
protected $title; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* The note's project_id. |
38
|
|
|
* |
39
|
|
|
* @var string |
40
|
|
|
*/ |
41
|
|
|
protected $project_id; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Describes who can edit this note. Can be either 'everyone' or 'owners'. |
45
|
|
|
* |
46
|
|
|
* @var string |
47
|
|
|
*/ |
48
|
|
|
protected $permissions; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* The note's body |
52
|
|
|
* |
53
|
|
|
* @var string |
54
|
|
|
*/ |
55
|
|
|
protected $content; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Creation time. |
59
|
|
|
* |
60
|
|
|
* @var \DateTime |
61
|
|
|
*/ |
62
|
|
|
protected $created_at; |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Last update time. |
66
|
|
|
* |
67
|
|
|
* @var \DateTime |
68
|
|
|
*/ |
69
|
|
|
protected $updated_at; |
70
|
|
|
|
71
|
|
|
public function __construct ($array) |
72
|
|
|
{ |
73
|
|
|
$this->arrayConstructionOnly = true; |
74
|
|
|
|
75
|
|
|
parent::__construct($array); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
// ================================================================================================================ |
79
|
|
|
// Getter functions |
80
|
|
|
// ================================================================================================================ |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* The collaboration box type (rich_text, file_list, faq_list). |
84
|
|
|
* |
85
|
|
|
* @return string |
86
|
|
|
*/ |
87
|
|
|
public function getType() |
88
|
|
|
{ |
89
|
|
|
return $this->type; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* The note's id. |
94
|
|
|
* |
95
|
|
|
* @return string |
96
|
|
|
*/ |
97
|
|
|
public function getId() |
98
|
|
|
{ |
99
|
|
|
return $this->id; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* The note's title. |
104
|
|
|
* |
105
|
|
|
* @return string |
106
|
|
|
*/ |
107
|
|
|
public function getTitle() |
108
|
|
|
{ |
109
|
|
|
return $this->title; |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* The note's project_id. |
114
|
|
|
* |
115
|
|
|
* @return string |
116
|
|
|
*/ |
117
|
|
|
public function getProjectId() |
118
|
|
|
{ |
119
|
|
|
return $this->project_id; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* Describes who can edit this note. Can be either 'everyone' or 'owners'. |
124
|
|
|
* |
125
|
|
|
* @return string |
126
|
|
|
*/ |
127
|
|
|
public function getPermissions() |
128
|
|
|
{ |
129
|
|
|
return $this->permissions; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* The note's body. |
134
|
|
|
* |
135
|
|
|
* @return string |
136
|
|
|
*/ |
137
|
|
|
public function getContent() |
138
|
|
|
{ |
139
|
|
|
return $this->content; |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* Creation time. |
144
|
|
|
* |
145
|
|
|
* @return \DateTime |
146
|
|
|
*/ |
147
|
|
|
public function getCreatedAt() |
148
|
|
|
{ |
149
|
|
|
return $this->created_at; |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* Last update time. |
154
|
|
|
* |
155
|
|
|
* @return \DateTime |
156
|
|
|
*/ |
157
|
|
|
public function getUpdatedAt() |
158
|
|
|
{ |
159
|
|
|
return $this->updated_at; |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
// ================================================================================================================ |
163
|
|
|
// Modification functions |
164
|
|
|
// ================================================================================================================ |
165
|
|
|
|
166
|
|
|
public function editNote ($title = NULL, $content = NULL, $user_id = NULL, $create_update = NULL) |
|
|
|
|
167
|
|
|
{ |
168
|
|
|
$this->checkInvalid(); |
169
|
|
|
|
170
|
|
|
$url = $this->getNotesUrl(); |
171
|
|
|
$postParams = array( |
172
|
|
|
"id" => $this->getProjectId(), |
173
|
|
|
"note_id" => $this->getId() |
174
|
|
|
); |
175
|
|
|
|
176
|
|
|
self::setIfNotNullOrEmpty($postParams, "title", $title); |
177
|
|
|
self::setIfNotNullOrEmpty($postParams, "content", $content); |
178
|
|
|
self::setIfNotNullOrEmpty($postParams, "user_id", $user_id); |
179
|
|
|
self::setIfNotNullOrEmpty($postParams, "create_update", $create_update); |
180
|
|
|
|
181
|
|
|
$this->jsonResponse = self::sendPut($url, $postParams); |
|
|
|
|
182
|
|
|
$this->assignResults(); |
183
|
|
|
|
184
|
|
|
return $this; |
185
|
|
|
} |
186
|
|
|
|
187
|
|
|
public function deleteNote () |
188
|
|
|
{ |
189
|
|
|
$this->checkInvalid(); |
190
|
|
|
|
191
|
|
|
self::sendDelete($this->getNotesUrl()); |
192
|
|
|
|
193
|
|
|
$this->deletedObject = true; |
194
|
|
|
} |
195
|
|
|
|
196
|
|
|
private function getNotesUrl () |
197
|
|
|
{ |
198
|
|
|
return sprintf("%s/%s/notes/%s.json", self::apiEndpoint(), $this->getProjectId(), $this->getId()); |
199
|
|
|
} |
200
|
|
|
} |
This check marks property names that have not been written in camelCase.
In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes
databaseConnectionString
.