1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Helix\Asana\Task; |
4
|
|
|
|
5
|
|
|
use Helix\Asana\Base\AbstractEntity; |
6
|
|
|
use Helix\Asana\Base\AbstractEntity\CrudTrait; |
7
|
|
|
use Helix\Asana\Task; |
8
|
|
|
use Helix\Asana\User; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* A task story. |
12
|
|
|
* |
13
|
|
|
* @see https://developers.asana.com/docs/asana-stories |
14
|
|
|
* @see https://developers.asana.com/docs/story |
15
|
|
|
* |
16
|
|
|
* @method string getCreatedAt () |
17
|
|
|
* @method null|User getCreatedBy () |
18
|
|
|
* @method string getHtmlText () |
19
|
|
|
* @method $this setHtmlText (string $text) |
20
|
|
|
* @method bool isLiked () |
21
|
|
|
* @method $this setLiked (string $liked) |
22
|
|
|
* @method User[] getLikes () |
23
|
|
|
* @method int getNumLikes () |
24
|
|
|
* @method string getResourceSubtype () |
25
|
|
|
* @method string getSource () |
26
|
|
|
* @method Task getTask () |
27
|
|
|
* @method string getText () |
28
|
|
|
* @method $this setText (string $text) |
29
|
|
|
*/ |
30
|
|
|
class Story extends AbstractEntity { |
31
|
|
|
|
32
|
|
|
use CrudTrait; |
33
|
|
|
|
34
|
|
|
const TYPE = 'story'; |
35
|
|
|
const TYPE_ASSIGNED = 'assigned'; |
36
|
|
|
const TYPE_COMMENT_ADDED = 'comment_added'; |
37
|
|
|
const TYPE_COMMENT_LIKED = 'comment_liked'; |
38
|
|
|
const TYPE_DUE_DATE_CHANGED = 'due_date_changed'; |
39
|
|
|
const TYPE_LIKED = 'liked'; |
40
|
|
|
const TYPE_TAGGED = 'added_to_tag'; |
41
|
|
|
|
42
|
|
|
protected static $map = [ |
43
|
|
|
'created_by' => User::class, |
44
|
|
|
'likes' => [User::class], |
45
|
|
|
'task' => Task::class |
46
|
|
|
]; |
47
|
|
|
|
48
|
|
|
final public function __toString (): string { |
49
|
|
|
return "stories/{$this->getGid()}"; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
final protected function _getDir (): string { |
53
|
|
|
return "{$this->getTask()}/stories"; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
final public function isAssignment (): bool { |
57
|
|
|
return $this->getResourceSubtype() === self::TYPE_ASSIGNED; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
final public function isComment (): bool { |
61
|
|
|
return $this->getResourceSubtype() === self::TYPE_COMMENT_ADDED; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
final public function isDueDate (): bool { |
65
|
|
|
return $this->getResourceSubtype() === self::TYPE_DUE_DATE_CHANGED; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
public function isEdited (): bool { |
69
|
|
|
return $this->_is('is_edited'); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
public function isPinned (): bool { |
73
|
|
|
return $this->_is('is_pinned'); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @param bool $pinned |
78
|
|
|
* @return $this |
79
|
|
|
*/ |
80
|
|
|
public function setPinned (bool $pinned) { |
81
|
|
|
return $this->_set('is_pinned', $pinned); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
} |