1 | <?php |
||
12 | class RocketChatAttachment |
||
13 | { |
||
14 | |||
15 | /** |
||
16 | * @var string The color you want the order on the left side to be, any value background-css supports. |
||
17 | */ |
||
18 | protected $color = ''; |
||
19 | |||
20 | /** |
||
21 | * @var string The text to display for this attachment, it is different than the message’s text. |
||
22 | */ |
||
23 | protected $text = ''; |
||
24 | /** |
||
25 | * @var string Displays the time next to the text portion. |
||
26 | */ |
||
27 | protected $timestamp = ''; |
||
28 | /** |
||
29 | * @var string An image that displays to the left of the text, looks better when this is relatively small. |
||
30 | */ |
||
31 | protected $thumbnailUrl = ''; |
||
32 | /** |
||
33 | * @var string Only applicable if the ts is provided, as it makes the time clickable to this link. |
||
34 | */ |
||
35 | protected $messageLink = ''; |
||
36 | /** |
||
37 | * @var bool Causes the image, audio, and video sections to be hiding when collapsed is true. |
||
38 | */ |
||
39 | protected $collapsed = false; |
||
40 | /** |
||
41 | * @var string Name of the author. |
||
42 | */ |
||
43 | protected $authorName = ''; |
||
44 | /** |
||
45 | * @var string Providing this makes the author name clickable and points to this link. |
||
46 | */ |
||
47 | protected $authorLink = ''; |
||
48 | /** |
||
49 | * @var string Displays a tiny icon to the left of the Author’s name. |
||
50 | */ |
||
51 | protected $authorIcon = ''; |
||
52 | /** |
||
53 | * @var string Title to display for this attachment, displays under the author. |
||
54 | */ |
||
55 | protected $title = ''; |
||
56 | /** |
||
57 | * @var string Providing this makes the title clickable, pointing to this link. |
||
58 | */ |
||
59 | protected $titleLink = ''; |
||
60 | /** |
||
61 | * @var bool When this is true, a download icon appears and clicking this saves the link to file. |
||
62 | */ |
||
63 | protected $titleLinkDownload = false; |
||
64 | /** |
||
65 | * @var string The image to display, will be “big” and easy to see. |
||
66 | */ |
||
67 | protected $imageUrl = ''; |
||
68 | /** |
||
69 | * @var string Audio file to play, only supports what html audio does. |
||
70 | */ |
||
71 | protected $audioUrl = ''; |
||
72 | /** |
||
73 | * @var string Video file to play, only supports what html video does. |
||
74 | */ |
||
75 | protected $videoUrl = ''; |
||
76 | /** |
||
77 | * @var array An array of Attachment Field Objects. |
||
78 | */ |
||
79 | protected $fields = []; |
||
80 | |||
81 | /** |
||
82 | * RocketChatAttachment constructor. |
||
83 | * @param array|null $config |
||
84 | */ |
||
85 | public function __construct(array $config = null) |
||
91 | |||
92 | |||
93 | /** |
||
94 | * Create a new instance of RocketChatAttachment |
||
95 | * |
||
96 | * @param array|null $config |
||
97 | * @return RocketChatAttachment |
||
98 | */ |
||
99 | public static function create(array $config = null) |
||
103 | |||
104 | /** |
||
105 | * set attachment data form array |
||
106 | * |
||
107 | * @param array $data |
||
108 | */ |
||
109 | protected function setFromArray(array $data) |
||
119 | |||
120 | /** |
||
121 | * @param string $color |
||
122 | * @return RocketChatAttachment |
||
123 | */ |
||
124 | public function color(string $color): self |
||
129 | |||
130 | /** |
||
131 | * @param string $text |
||
132 | * @return RocketChatAttachment |
||
133 | */ |
||
134 | public function text(string $text): self |
||
139 | |||
140 | /** |
||
141 | * @param string|\DateTime $timestamp |
||
142 | * @return RocketChatAttachment |
||
143 | */ |
||
144 | public function timestamp($timestamp): self |
||
157 | |||
158 | /** |
||
159 | * @param string $thumbnailUrl |
||
160 | * @return RocketChatAttachment |
||
161 | */ |
||
162 | public function thumbnailUrl(string $thumbnailUrl): self |
||
167 | |||
168 | /** |
||
169 | * @param string $messageLink |
||
170 | * @return RocketChatAttachment |
||
171 | */ |
||
172 | public function messageLink(string $messageLink): self |
||
177 | |||
178 | /** |
||
179 | * @param bool $collapsed |
||
180 | * @return RocketChatAttachment |
||
181 | */ |
||
182 | public function collapsed(bool $collapsed): self |
||
187 | |||
188 | /** |
||
189 | * @param string $name |
||
190 | * @param string $link |
||
191 | * @param string $icon |
||
192 | * @return RocketChatAttachment |
||
193 | */ |
||
194 | public function author(string $name, string $link = '', string $icon = ''): self |
||
201 | |||
202 | /** |
||
203 | * @param string $authorName |
||
204 | * @return RocketChatAttachment |
||
205 | */ |
||
206 | public function authorName(string $authorName): self |
||
211 | |||
212 | /** |
||
213 | * @param string $authorLink |
||
214 | * @return RocketChatAttachment |
||
215 | */ |
||
216 | public function authorLink(string $authorLink): self |
||
221 | |||
222 | /** |
||
223 | * @param string $authorIcon |
||
224 | * @return RocketChatAttachment |
||
225 | */ |
||
226 | public function authorIcon(string $authorIcon): self |
||
231 | |||
232 | /** |
||
233 | * @param string $title |
||
234 | * @return RocketChatAttachment |
||
235 | */ |
||
236 | public function title(string $title): self |
||
241 | |||
242 | /** |
||
243 | * @param string $titleLink |
||
244 | * @return RocketChatAttachment |
||
245 | */ |
||
246 | public function titleLink(string $titleLink): self |
||
251 | |||
252 | /** |
||
253 | * @param bool $titleLinkDownload |
||
254 | * @return RocketChatAttachment |
||
255 | */ |
||
256 | public function titleLinkDownload(bool $titleLinkDownload): self |
||
261 | |||
262 | /** |
||
263 | * @param string $imageUrl |
||
264 | * @return RocketChatAttachment |
||
265 | */ |
||
266 | public function imageUrl(string $imageUrl): self |
||
271 | |||
272 | /** |
||
273 | * @param string $audioUrl |
||
274 | * @return RocketChatAttachment |
||
275 | */ |
||
276 | public function audioUrl(string $audioUrl): self |
||
281 | |||
282 | /** |
||
283 | * @param string $videoUrl |
||
284 | * @return RocketChatAttachment |
||
285 | */ |
||
286 | public function videoUrl(string $videoUrl): self |
||
291 | |||
292 | /** |
||
293 | * @param array $fields |
||
294 | * @return RocketChatAttachment |
||
295 | */ |
||
296 | public function fields(array $fields): self |
||
301 | |||
302 | |||
303 | /** |
||
304 | * Get an array representation of the RocketChatAttachment. |
||
305 | * |
||
306 | * @return array |
||
307 | */ |
||
308 | public function toArray() : array |
||
331 | |||
332 | |||
333 | } |
||
334 |