1 | <?php |
||
12 | class RocketChatAttachment |
||
13 | { |
||
14 | /** |
||
15 | * @var string The color you want the order on the left side to be, any value background-css supports. |
||
16 | */ |
||
17 | protected $color = ''; |
||
18 | |||
19 | /** |
||
20 | * @var string The text to display for this attachment, it is different than the message’s text. |
||
21 | */ |
||
22 | protected $text = ''; |
||
23 | /** |
||
24 | * @var string Displays the time next to the text portion. |
||
25 | */ |
||
26 | protected $timestamp = ''; |
||
27 | /** |
||
28 | * @var string An image that displays to the left of the text, looks better when this is relatively small. |
||
29 | */ |
||
30 | protected $thumbnailUrl = ''; |
||
31 | /** |
||
32 | * @var string Only applicable if the ts is provided, as it makes the time clickable to this link. |
||
33 | */ |
||
34 | protected $messageLink = ''; |
||
35 | /** |
||
36 | * @var bool Causes the image, audio, and video sections to be hiding when collapsed is true. |
||
37 | */ |
||
38 | protected $collapsed = false; |
||
39 | /** |
||
40 | * @var string Name of the author. |
||
41 | */ |
||
42 | protected $authorName = ''; |
||
43 | /** |
||
44 | * @var string Providing this makes the author name clickable and points to this link. |
||
45 | */ |
||
46 | protected $authorLink = ''; |
||
47 | /** |
||
48 | * @var string Displays a tiny icon to the left of the Author’s name. |
||
49 | */ |
||
50 | protected $authorIcon = ''; |
||
51 | /** |
||
52 | * @var string Title to display for this attachment, displays under the author. |
||
53 | */ |
||
54 | protected $title = ''; |
||
55 | /** |
||
56 | * @var string Providing this makes the title clickable, pointing to this link. |
||
57 | */ |
||
58 | protected $titleLink = ''; |
||
59 | /** |
||
60 | * @var bool When this is true, a download icon appears and clicking this saves the link to file. |
||
61 | */ |
||
62 | protected $titleLinkDownload = false; |
||
63 | /** |
||
64 | * @var string The image to display, will be “big” and easy to see. |
||
65 | */ |
||
66 | protected $imageUrl = ''; |
||
67 | /** |
||
68 | * @var string Audio file to play, only supports what html audio does. |
||
69 | */ |
||
70 | protected $audioUrl = ''; |
||
71 | /** |
||
72 | * @var string Video file to play, only supports what html video does. |
||
73 | */ |
||
74 | protected $videoUrl = ''; |
||
75 | /** |
||
76 | * @var array An array of Attachment Field Objects. |
||
77 | */ |
||
78 | protected $fields = []; |
||
79 | |||
80 | /** |
||
81 | * RocketChatAttachment constructor. |
||
82 | * @param array|null $config |
||
83 | */ |
||
84 | 26 | public function __construct(array $config = null) |
|
90 | |||
91 | /** |
||
92 | * Create a new instance of RocketChatAttachment. |
||
93 | * |
||
94 | * @param array|null $config |
||
95 | * @return RocketChatAttachment |
||
96 | */ |
||
97 | 4 | public static function create(array $config = null) |
|
101 | |||
102 | /** |
||
103 | * set attachment data form array. |
||
104 | * |
||
105 | * @param array $data |
||
106 | */ |
||
107 | 5 | protected function setFromArray(array $data) |
|
117 | |||
118 | /** |
||
119 | * @param string $color |
||
120 | * @return RocketChatAttachment |
||
121 | */ |
||
122 | 1 | public function color(string $color): self |
|
128 | |||
129 | /** |
||
130 | * @param string $text |
||
131 | * @return RocketChatAttachment |
||
132 | */ |
||
133 | 1 | public function text(string $text): self |
|
139 | |||
140 | /** |
||
141 | * @param string|\DateTime $timestamp |
||
142 | * @return RocketChatAttachment |
||
143 | */ |
||
144 | 2 | public function timestamp($timestamp): self |
|
158 | |||
159 | /** |
||
160 | * @param string $thumbnailUrl |
||
161 | * @return RocketChatAttachment |
||
162 | */ |
||
163 | 1 | public function thumbnailUrl(string $thumbnailUrl): self |
|
169 | |||
170 | /** |
||
171 | * @param string $messageLink |
||
172 | * @return RocketChatAttachment |
||
173 | */ |
||
174 | 1 | public function messageLink(string $messageLink): self |
|
180 | |||
181 | /** |
||
182 | * @param bool $collapsed |
||
183 | * @return RocketChatAttachment |
||
184 | */ |
||
185 | 1 | public function collapsed(bool $collapsed): self |
|
191 | |||
192 | /** |
||
193 | * @param string $name |
||
194 | * @param string $link |
||
195 | * @param string $icon |
||
196 | * @return RocketChatAttachment |
||
197 | */ |
||
198 | 1 | public function author(string $name, string $link = '', string $icon = ''): self |
|
206 | |||
207 | /** |
||
208 | * @param string $authorName |
||
209 | * @return RocketChatAttachment |
||
210 | */ |
||
211 | 2 | public function authorName(string $authorName): self |
|
217 | |||
218 | /** |
||
219 | * @param string $authorLink |
||
220 | * @return RocketChatAttachment |
||
221 | */ |
||
222 | 2 | public function authorLink(string $authorLink): self |
|
228 | |||
229 | /** |
||
230 | * @param string $authorIcon |
||
231 | * @return RocketChatAttachment |
||
232 | */ |
||
233 | 2 | public function authorIcon(string $authorIcon): self |
|
239 | |||
240 | /** |
||
241 | * @param string $title |
||
242 | * @return RocketChatAttachment |
||
243 | */ |
||
244 | 5 | public function title(string $title): self |
|
250 | |||
251 | /** |
||
252 | * @param string $titleLink |
||
253 | * @return RocketChatAttachment |
||
254 | */ |
||
255 | 1 | public function titleLink(string $titleLink): self |
|
261 | |||
262 | /** |
||
263 | * @param bool $titleLinkDownload |
||
264 | * @return RocketChatAttachment |
||
265 | */ |
||
266 | 1 | public function titleLinkDownload(bool $titleLinkDownload): self |
|
272 | |||
273 | /** |
||
274 | * @param string $imageUrl |
||
275 | * @return RocketChatAttachment |
||
276 | */ |
||
277 | 1 | public function imageUrl(string $imageUrl): self |
|
283 | |||
284 | /** |
||
285 | * @param string $audioUrl |
||
286 | * @return RocketChatAttachment |
||
287 | */ |
||
288 | 1 | public function audioUrl(string $audioUrl): self |
|
294 | |||
295 | /** |
||
296 | * @param string $videoUrl |
||
297 | * @return RocketChatAttachment |
||
298 | */ |
||
299 | 1 | public function videoUrl(string $videoUrl): self |
|
305 | |||
306 | /** |
||
307 | * @param array $fields |
||
308 | * @return RocketChatAttachment |
||
309 | */ |
||
310 | 1 | public function fields(array $fields): self |
|
316 | |||
317 | /** |
||
318 | * Get an array representation of the RocketChatAttachment. |
||
319 | * |
||
320 | * @return array |
||
321 | */ |
||
322 | 22 | public function toArray(): array |
|
345 | } |
||
346 |