1 | <?php |
||
12 | class RocketChatAttachment |
||
13 | { |
||
14 | /** @var string|null The color you want the order on the left side to be, any value background-css supports. */ |
||
15 | protected $color; |
||
16 | |||
17 | /** @var string|null The text to display for this attachment, it is different than the message’s text. */ |
||
18 | protected $text; |
||
19 | |||
20 | /** @var string|null Displays the time next to the text portion. */ |
||
21 | protected $timestamp; |
||
22 | |||
23 | /** @var string|null An image that displays to the left of the text, looks better when this is relatively small. */ |
||
24 | protected $thumbnailUrl; |
||
25 | |||
26 | /** @var string|null Only applicable if the ts is provided, as it makes the time clickable to this link. */ |
||
27 | protected $messageLink; |
||
28 | |||
29 | /** @var bool Causes the image, audio, and video sections to be hiding when collapsed is true. */ |
||
30 | protected $collapsed = false; |
||
31 | |||
32 | /** @var string|null Name of the author. */ |
||
33 | protected $authorName; |
||
34 | |||
35 | /** @var string|null Providing this makes the author name clickable and points to this link. */ |
||
36 | protected $authorLink; |
||
37 | |||
38 | /** @var string|null Displays a tiny icon to the left of the Author’s name. */ |
||
39 | protected $authorIcon; |
||
40 | |||
41 | /** @var string|null Title to display for this attachment, displays under the author. */ |
||
42 | protected $title; |
||
43 | |||
44 | /** @var string|null Providing this makes the title clickable, pointing to this link. */ |
||
45 | protected $titleLink; |
||
46 | |||
47 | /** @var bool When this is true, a download icon appears and clicking this saves the link to file. */ |
||
48 | protected $titleLinkDownload = false; |
||
49 | |||
50 | /** @var string|null The image to display, will be “big” and easy to see. */ |
||
51 | protected $imageUrl; |
||
52 | |||
53 | /** @var string|null Audio file to play, only supports what html audio does. */ |
||
54 | protected $audioUrl; |
||
55 | |||
56 | /** @var string|null Video file to play, only supports what html video does. */ |
||
57 | protected $videoUrl; |
||
58 | |||
59 | /** @var array An array of Attachment Field Objects. */ |
||
60 | protected $fields = []; |
||
61 | |||
62 | /** |
||
63 | * RocketChatAttachment constructor. |
||
64 | * |
||
65 | * @param array $data |
||
66 | */ |
||
67 | 26 | public function __construct(array $data = []) |
|
71 | |||
72 | /** |
||
73 | * Create a new instance of RocketChatAttachment. |
||
74 | * |
||
75 | * @param array $data |
||
76 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
77 | */ |
||
78 | 4 | public static function make(array $data = []) |
|
82 | |||
83 | /** |
||
84 | * @param string $color |
||
85 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
86 | */ |
||
87 | 1 | public function color(string $color): self |
|
93 | |||
94 | /** |
||
95 | * @param string $text |
||
96 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
97 | */ |
||
98 | 1 | public function text(string $text): self |
|
104 | |||
105 | /** |
||
106 | * @param string|\DateTime $timestamp |
||
107 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
108 | */ |
||
109 | 2 | public function timestamp($timestamp): self |
|
127 | |||
128 | /** |
||
129 | * @param string $thumbnailUrl |
||
130 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
131 | */ |
||
132 | 1 | public function thumbnailUrl(string $thumbnailUrl): self |
|
138 | |||
139 | /** |
||
140 | * @param string $messageLink |
||
141 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
142 | */ |
||
143 | 1 | public function messageLink(string $messageLink): self |
|
149 | |||
150 | /** |
||
151 | * @param bool $collapsed |
||
152 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
153 | */ |
||
154 | 1 | public function collapsed(bool $collapsed): self |
|
160 | |||
161 | /** |
||
162 | * @param string $name |
||
163 | * @param string $link |
||
164 | * @param string $icon |
||
165 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
166 | */ |
||
167 | 1 | public function author(string $name, string $link = '', string $icon = ''): self |
|
175 | |||
176 | /** |
||
177 | * @param string $authorName |
||
178 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
179 | */ |
||
180 | 2 | public function authorName(string $authorName): self |
|
186 | |||
187 | /** |
||
188 | * @param string $authorLink |
||
189 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
190 | */ |
||
191 | 2 | public function authorLink(string $authorLink): self |
|
197 | |||
198 | /** |
||
199 | * @param string $authorIcon |
||
200 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
201 | */ |
||
202 | 2 | public function authorIcon(string $authorIcon): self |
|
208 | |||
209 | /** |
||
210 | * @param string $title |
||
211 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
212 | */ |
||
213 | 5 | public function title(string $title): self |
|
219 | |||
220 | /** |
||
221 | * @param string $titleLink |
||
222 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
223 | */ |
||
224 | 1 | public function titleLink(string $titleLink): self |
|
230 | |||
231 | /** |
||
232 | * @param bool $titleLinkDownload |
||
233 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
234 | */ |
||
235 | 1 | public function titleLinkDownload(bool $titleLinkDownload): self |
|
241 | |||
242 | /** |
||
243 | * @param string $imageUrl |
||
244 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
245 | */ |
||
246 | 1 | public function imageUrl(string $imageUrl): self |
|
252 | |||
253 | /** |
||
254 | * @param string $audioUrl |
||
255 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
256 | */ |
||
257 | 1 | public function audioUrl(string $audioUrl): self |
|
263 | |||
264 | /** |
||
265 | * @param string $videoUrl |
||
266 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
267 | */ |
||
268 | 1 | public function videoUrl(string $videoUrl): self |
|
274 | |||
275 | /** |
||
276 | * @param array $fields |
||
277 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
278 | */ |
||
279 | 1 | public function fields(array $fields): self |
|
285 | |||
286 | /** |
||
287 | * Get an array representation of the RocketChatAttachment. |
||
288 | * |
||
289 | * @return array |
||
290 | */ |
||
291 | 25 | public function toArray(): array |
|
312 | |||
313 | /** |
||
314 | * Set attachment data from array. |
||
315 | * |
||
316 | * @param array $data |
||
317 | * @return void |
||
318 | */ |
||
319 | 26 | private function setPropertiesFromArray(array $data): void |
|
331 | } |
||
332 |