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 |
|
124 | |||
125 | /** |
||
126 | * @param string $thumbnailUrl |
||
127 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
128 | */ |
||
129 | 1 | public function thumbnailUrl(string $thumbnailUrl): self |
|
135 | |||
136 | /** |
||
137 | * @param string $messageLink |
||
138 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
139 | */ |
||
140 | 1 | public function messageLink(string $messageLink): self |
|
146 | |||
147 | /** |
||
148 | * @param bool $collapsed |
||
149 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
150 | */ |
||
151 | 1 | public function collapsed(bool $collapsed): self |
|
157 | |||
158 | /** |
||
159 | * @param string $name |
||
160 | * @param string $link |
||
161 | * @param string $icon |
||
162 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
163 | */ |
||
164 | 1 | public function author(string $name, string $link = '', string $icon = ''): self |
|
172 | |||
173 | /** |
||
174 | * @param string $authorName |
||
175 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
176 | */ |
||
177 | 2 | public function authorName(string $authorName): self |
|
183 | |||
184 | /** |
||
185 | * @param string $authorLink |
||
186 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
187 | */ |
||
188 | 2 | public function authorLink(string $authorLink): self |
|
194 | |||
195 | /** |
||
196 | * @param string $authorIcon |
||
197 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
198 | */ |
||
199 | 2 | public function authorIcon(string $authorIcon): self |
|
205 | |||
206 | /** |
||
207 | * @param string $title |
||
208 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
209 | */ |
||
210 | 5 | public function title(string $title): self |
|
216 | |||
217 | /** |
||
218 | * @param string $titleLink |
||
219 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
220 | */ |
||
221 | 1 | public function titleLink(string $titleLink): self |
|
227 | |||
228 | /** |
||
229 | * @param bool $titleLinkDownload |
||
230 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
231 | */ |
||
232 | 1 | public function titleLinkDownload(bool $titleLinkDownload): self |
|
238 | |||
239 | /** |
||
240 | * @param string $imageUrl |
||
241 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
242 | */ |
||
243 | 1 | public function imageUrl(string $imageUrl): self |
|
249 | |||
250 | /** |
||
251 | * @param string $audioUrl |
||
252 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
253 | */ |
||
254 | 1 | public function audioUrl(string $audioUrl): self |
|
260 | |||
261 | /** |
||
262 | * @param string $videoUrl |
||
263 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
264 | */ |
||
265 | 1 | public function videoUrl(string $videoUrl): self |
|
271 | |||
272 | /** |
||
273 | * @param array $fields |
||
274 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
275 | */ |
||
276 | 1 | public function fields(array $fields): self |
|
282 | |||
283 | /** |
||
284 | * Get an array representation of the RocketChatAttachment. |
||
285 | * |
||
286 | * @return array |
||
287 | */ |
||
288 | 25 | public function toArray(): array |
|
309 | |||
310 | /** |
||
311 | * Set attachment data from array. |
||
312 | * |
||
313 | * @param array $data |
||
314 | * @return void |
||
315 | */ |
||
316 | 26 | private function setPropertiesFromArray(array $data): void |
|
328 | } |
||
329 |