1 | <?php |
||
19 | class PulseUser extends ApiObject |
||
20 | { |
||
21 | /** |
||
22 | * {@inheritdoc} |
||
23 | */ |
||
24 | const API_PREFIX = "users"; |
||
25 | |||
26 | /** |
||
27 | * The resource's URL. |
||
28 | * |
||
29 | * @var string |
||
30 | */ |
||
31 | protected $url; |
||
32 | |||
33 | /** |
||
34 | * The user's name. |
||
35 | * |
||
36 | * @var string |
||
37 | */ |
||
38 | protected $name; |
||
39 | |||
40 | /** |
||
41 | * The user's email. |
||
42 | * |
||
43 | * @var string |
||
44 | */ |
||
45 | protected $email; |
||
46 | |||
47 | /** |
||
48 | * The user's photo_url. |
||
49 | * |
||
50 | * @var string |
||
51 | */ |
||
52 | protected $photo_url; |
||
53 | |||
54 | /** |
||
55 | * The user's title. |
||
56 | * |
||
57 | * @var string |
||
58 | */ |
||
59 | protected $title; |
||
60 | |||
61 | /** |
||
62 | * The user's position. |
||
63 | * |
||
64 | * @var string |
||
65 | */ |
||
66 | protected $position; |
||
67 | |||
68 | /** |
||
69 | * The user's phone. |
||
70 | * |
||
71 | * @var string |
||
72 | */ |
||
73 | protected $phone; |
||
74 | |||
75 | /** |
||
76 | * The user's location. |
||
77 | * |
||
78 | * @var string |
||
79 | */ |
||
80 | protected $location; |
||
81 | |||
82 | /** |
||
83 | * The user's status. |
||
84 | * |
||
85 | * @var string |
||
86 | */ |
||
87 | protected $status; |
||
88 | |||
89 | /** |
||
90 | * The user's birthday. |
||
91 | * |
||
92 | * @var string |
||
93 | */ |
||
94 | protected $birthday; |
||
95 | |||
96 | /** |
||
97 | * True if the user is guest, false otherwise |
||
98 | * |
||
99 | * @var bool |
||
100 | */ |
||
101 | protected $is_guest; |
||
102 | |||
103 | /** |
||
104 | * The user's skills. |
||
105 | * |
||
106 | * @var string[] |
||
107 | */ |
||
108 | protected $skills; |
||
109 | |||
110 | /** |
||
111 | * Creation time. |
||
112 | * |
||
113 | * @var \DateTime |
||
114 | */ |
||
115 | protected $created_at; |
||
116 | |||
117 | /** |
||
118 | * Last update time. |
||
119 | * |
||
120 | * @var \DateTime |
||
121 | */ |
||
122 | protected $updated_at; |
||
123 | |||
124 | /** |
||
125 | * The membership type of this user with respect to a specific Pulse or PulseBoard. This value will not be set if |
||
126 | * a PulseUser object is created standalone and not by another object which supports subscribers or membership. |
||
127 | * |
||
128 | * @var mixed |
||
129 | */ |
||
130 | protected $membership; |
||
131 | |||
132 | /** |
||
133 | * The URL pattern used for all calls |
||
134 | * |
||
135 | * @var string |
||
136 | */ |
||
137 | private $urlSyntax = "%s/%s/%s.json"; |
||
138 | |||
139 | // ================================================================================================================ |
||
140 | // Getter functions |
||
141 | // ================================================================================================================ |
||
142 | |||
143 | /** |
||
144 | * The resource's URL. |
||
145 | * |
||
146 | * @api |
||
147 | * |
||
148 | * @since 0.1.0 |
||
149 | * |
||
150 | * @return string |
||
151 | */ |
||
152 | public function getUrl () |
||
158 | |||
159 | /** |
||
160 | * The user's unique identifier. |
||
161 | * |
||
162 | * @api |
||
163 | * |
||
164 | * @since 0.1.0 |
||
165 | * |
||
166 | * @return int |
||
167 | */ |
||
168 | 8 | public function getId () |
|
169 | { |
||
170 | 8 | return $this->id; |
|
171 | } |
||
172 | |||
173 | /** |
||
174 | * The user's name. |
||
175 | * |
||
176 | * @api |
||
177 | * |
||
178 | * @since 0.1.0 |
||
179 | * |
||
180 | * @return string |
||
181 | */ |
||
182 | public function getName () |
||
188 | |||
189 | /** |
||
190 | * The user's email. |
||
191 | * |
||
192 | * @api |
||
193 | * |
||
194 | * @since 0.1.0 |
||
195 | * |
||
196 | * @return string |
||
197 | */ |
||
198 | public function getEmail () |
||
204 | |||
205 | /** |
||
206 | * The user's photo_url. |
||
207 | * |
||
208 | * @api |
||
209 | * |
||
210 | * @since 0.1.0 |
||
211 | * |
||
212 | * @return string |
||
213 | */ |
||
214 | public function getPhotoUrl () |
||
220 | |||
221 | /** |
||
222 | * The user's title. |
||
223 | * |
||
224 | * @api |
||
225 | * |
||
226 | * @since 0.1.0 |
||
227 | * |
||
228 | * @return string |
||
229 | */ |
||
230 | public function getTitle () |
||
236 | |||
237 | /** |
||
238 | * The user's position. |
||
239 | * |
||
240 | * @api |
||
241 | * |
||
242 | * @since 0.1.0 |
||
243 | * |
||
244 | * @return string |
||
245 | */ |
||
246 | public function getPosition () |
||
252 | |||
253 | /** |
||
254 | * The user's phone. |
||
255 | * |
||
256 | * @api |
||
257 | * |
||
258 | * @since 0.1.0 |
||
259 | * |
||
260 | * @return string |
||
261 | */ |
||
262 | public function getPhone () |
||
268 | |||
269 | /** |
||
270 | * The user's location. |
||
271 | * |
||
272 | * @api |
||
273 | * |
||
274 | * @since 0.1.0 |
||
275 | * |
||
276 | * @return string |
||
277 | */ |
||
278 | public function getLocation () |
||
284 | |||
285 | /** |
||
286 | * The user's status. |
||
287 | * |
||
288 | * @api |
||
289 | * |
||
290 | * @since 0.1.0 |
||
291 | * |
||
292 | * @return string |
||
293 | */ |
||
294 | public function getStatus () |
||
300 | |||
301 | /** |
||
302 | * The user's birthday. |
||
303 | * |
||
304 | * @api |
||
305 | * |
||
306 | * @since 0.1.0 |
||
307 | * |
||
308 | * @return string |
||
309 | */ |
||
310 | public function getBirthday () |
||
316 | |||
317 | /** |
||
318 | * True if the user is guest, false otherwise |
||
319 | * |
||
320 | * @api |
||
321 | * @todo Remove this function at 0.4.0 or next breaking release |
||
|
|||
322 | * @deprecated 0.3.0 Use PulseUser::isGuest() instead |
||
323 | * @since 0.1.0 |
||
324 | * @return bool |
||
325 | */ |
||
326 | public function getIsGuest () |
||
330 | |||
331 | /** |
||
332 | * The user's skills. |
||
333 | * |
||
334 | * @api |
||
335 | * |
||
336 | * @since 0.1.0 |
||
337 | * |
||
338 | * @return string[] |
||
339 | */ |
||
340 | public function getSkills () |
||
346 | |||
347 | /** |
||
348 | * Creation time. |
||
349 | * |
||
350 | * @api |
||
351 | * |
||
352 | * @since 0.1.0 |
||
353 | * |
||
354 | * @return \DateTime |
||
355 | */ |
||
356 | public function getCreatedAt () |
||
363 | |||
364 | /** |
||
365 | * Last update time. |
||
366 | * |
||
367 | * @api |
||
368 | * |
||
369 | * @since 0.1.0 |
||
370 | * |
||
371 | * @return \DateTime |
||
372 | */ |
||
373 | public function getUpdatedAt () |
||
380 | |||
381 | /** |
||
382 | * True if the user is guest, false otherwise |
||
383 | * |
||
384 | * @api |
||
385 | * |
||
386 | * @since 0.3.0 |
||
387 | * |
||
388 | * @return bool |
||
389 | */ |
||
390 | public function isGuest () |
||
396 | |||
397 | /** |
||
398 | * Get the user's newsfeed |
||
399 | * |
||
400 | * @api |
||
401 | * |
||
402 | * @param array $params GET parameters that need to be passed in the URL |
||
403 | * |
||
404 | * @since 0.1.0 |
||
405 | * |
||
406 | * @return PulseUpdate[] An array of PulseUpdates that make up the user's newsfeed |
||
407 | */ |
||
408 | public function getNewsFeed ($params = []) |
||
414 | |||
415 | /** |
||
416 | * Get the user's posts |
||
417 | * |
||
418 | * @api |
||
419 | * |
||
420 | * @param array $params GET parameters that need to be passed in the URL |
||
421 | * |
||
422 | * @since 0.1.0 |
||
423 | * |
||
424 | * @return PulseUpdate[] An array of PulseUpdates for each of the posts |
||
425 | */ |
||
426 | public function getPosts ($params = []) |
||
432 | |||
433 | /** |
||
434 | * Get the user's unread posts |
||
435 | * |
||
436 | * @api |
||
437 | * |
||
438 | * @param array $params GET parameters that need to be passed in the URL |
||
439 | * |
||
440 | * @since 0.1.0 |
||
441 | * |
||
442 | * @return PulseUpdate[] An array of PulseUpdates for each of the posts |
||
443 | */ |
||
444 | public function getUnreadFeed ($params = []) |
||
450 | |||
451 | /** |
||
452 | * Get all of the users |
||
453 | * |
||
454 | * @api |
||
455 | * |
||
456 | * @param array $params GET parameters that need to be passed in the URL |
||
457 | * |
||
458 | * @since 0.1.0 |
||
459 | * |
||
460 | * @return PulseUser[] An array of PulseUsers for each of the users |
||
461 | */ |
||
462 | public static function getUsers ($params = []) |
||
468 | |||
469 | // ================================================================================================================= |
||
470 | // Convenience functions |
||
471 | // ================================================================================================================= |
||
472 | |||
473 | /** |
||
474 | * Check whether a given value can be casted or used to get a user ID |
||
475 | * |
||
476 | * @internal |
||
477 | * |
||
478 | * @param int|PulseUser $user |
||
479 | * |
||
480 | * @since 0.3.0 |
||
481 | * |
||
482 | * @throws \InvalidArgumentException if $user is not an integer, is not positive, or is not a PulseUser object |
||
483 | */ |
||
484 | 12 | public static function _isCastable ($user) |
|
491 | |||
492 | /** |
||
493 | * @internal |
||
494 | * |
||
495 | * @param int|PulseUser $user |
||
496 | * |
||
497 | * @since 0.3.0 |
||
498 | * |
||
499 | * @return int |
||
500 | */ |
||
501 | 12 | public static function _castToInt ($user) |
|
507 | } |
This check looks
TODO
comments that have been left in the code.``TODO``s show that something is left unfinished and should be attended to.