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 | 27 | 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 | 3 | 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|\DateTimeInterface $timestamp |
||
107 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
108 | */ |
||
109 | 4 | public function timestamp($timestamp): self |
|
131 | |||
132 | /** |
||
133 | * @param string $thumbnailUrl |
||
134 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
135 | */ |
||
136 | 1 | public function thumbnailUrl(string $thumbnailUrl): self |
|
142 | |||
143 | /** |
||
144 | * @param string $messageLink |
||
145 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
146 | */ |
||
147 | 1 | public function messageLink(string $messageLink): self |
|
153 | |||
154 | /** |
||
155 | * @param bool $collapsed |
||
156 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
157 | */ |
||
158 | 1 | public function collapsed(bool $collapsed): self |
|
164 | |||
165 | /** |
||
166 | * @param string $name |
||
167 | * @param string $link |
||
168 | * @param string $icon |
||
169 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
170 | */ |
||
171 | 1 | public function author(string $name, string $link = '', string $icon = ''): self |
|
179 | |||
180 | /** |
||
181 | * @param string $authorName |
||
182 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
183 | */ |
||
184 | 2 | public function authorName(string $authorName): self |
|
190 | |||
191 | /** |
||
192 | * @param string $authorLink |
||
193 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
194 | */ |
||
195 | 2 | public function authorLink(string $authorLink): self |
|
201 | |||
202 | /** |
||
203 | * @param string $authorIcon |
||
204 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
205 | */ |
||
206 | 2 | public function authorIcon(string $authorIcon): self |
|
212 | |||
213 | /** |
||
214 | * @param string $title |
||
215 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
216 | */ |
||
217 | 5 | public function title(string $title): self |
|
223 | |||
224 | /** |
||
225 | * @param string $titleLink |
||
226 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
227 | */ |
||
228 | 1 | public function titleLink(string $titleLink): self |
|
234 | |||
235 | /** |
||
236 | * @param bool $titleLinkDownload |
||
237 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
238 | */ |
||
239 | 1 | public function titleLinkDownload(bool $titleLinkDownload): self |
|
245 | |||
246 | /** |
||
247 | * @param string $imageUrl |
||
248 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
249 | */ |
||
250 | 1 | public function imageUrl(string $imageUrl): self |
|
256 | |||
257 | /** |
||
258 | * @param string $audioUrl |
||
259 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
260 | */ |
||
261 | 1 | public function audioUrl(string $audioUrl): self |
|
267 | |||
268 | /** |
||
269 | * @param string $videoUrl |
||
270 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
271 | */ |
||
272 | 1 | public function videoUrl(string $videoUrl): self |
|
278 | |||
279 | /** |
||
280 | * @param array $fields |
||
281 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
282 | */ |
||
283 | 1 | public function fields(array $fields): self |
|
289 | |||
290 | /** |
||
291 | * Get an array representation of the RocketChatAttachment. |
||
292 | * |
||
293 | * @return array |
||
294 | */ |
||
295 | 26 | public function toArray(): array |
|
316 | |||
317 | /** |
||
318 | * Set attachment data from array. |
||
319 | * |
||
320 | * @param array $data |
||
321 | * @return void |
||
322 | */ |
||
323 | 27 | private function setPropertiesFromArray(array $data): void |
|
335 | } |
||
336 |