1 | <?php |
||
12 | class RocketChatAttachment |
||
13 | { |
||
14 | /** @var string The color you want the order on the left side to be, any value background-css supports. */ |
||
15 | protected $color = ''; |
||
16 | |||
17 | /** @var string The text to display for this attachment, it is different than the message’s text. */ |
||
18 | protected $text = ''; |
||
19 | |||
20 | /** @var string Displays the time next to the text portion. */ |
||
21 | protected $timestamp = ''; |
||
22 | |||
23 | /** @var string An image that displays to the left of the text, looks better when this is relatively small. */ |
||
24 | protected $thumbnailUrl = ''; |
||
25 | |||
26 | /** @var string 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 Name of the author. */ |
||
33 | protected $authorName = ''; |
||
34 | |||
35 | /** @var string Providing this makes the author name clickable and points to this link. */ |
||
36 | protected $authorLink = ''; |
||
37 | |||
38 | /** @var string Displays a tiny icon to the left of the Author’s name. */ |
||
39 | protected $authorIcon = ''; |
||
40 | |||
41 | /** @var string Title to display for this attachment, displays under the author. */ |
||
42 | protected $title = ''; |
||
43 | |||
44 | /** @var string 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 The image to display, will be “big” and easy to see. */ |
||
51 | protected $imageUrl = ''; |
||
52 | |||
53 | /** @var string Audio file to play, only supports what html audio does. */ |
||
54 | protected $audioUrl = ''; |
||
55 | |||
56 | /** @var string 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 RocketChatAttachment |
||
77 | */ |
||
78 | 4 | public static function make(array $data = []) |
|
82 | |||
83 | /** |
||
84 | * @param string $color |
||
85 | * @return 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 |
|
123 | |||
124 | /** |
||
125 | * @param string $thumbnailUrl |
||
126 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
127 | */ |
||
128 | 1 | public function thumbnailUrl(string $thumbnailUrl): self |
|
134 | |||
135 | /** |
||
136 | * @param string $messageLink |
||
137 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
138 | */ |
||
139 | 1 | public function messageLink(string $messageLink): self |
|
145 | |||
146 | /** |
||
147 | * @param bool $collapsed |
||
148 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
149 | */ |
||
150 | 1 | public function collapsed(bool $collapsed): self |
|
156 | |||
157 | /** |
||
158 | * @param string $name |
||
159 | * @param string $link |
||
160 | * @param string $icon |
||
161 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
162 | */ |
||
163 | 1 | public function author(string $name, string $link = '', string $icon = ''): self |
|
171 | |||
172 | /** |
||
173 | * @param string $authorName |
||
174 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
175 | */ |
||
176 | 2 | public function authorName(string $authorName): self |
|
182 | |||
183 | /** |
||
184 | * @param string $authorLink |
||
185 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
186 | */ |
||
187 | 2 | public function authorLink(string $authorLink): self |
|
193 | |||
194 | /** |
||
195 | * @param string $authorIcon |
||
196 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
197 | */ |
||
198 | 2 | public function authorIcon(string $authorIcon): self |
|
204 | |||
205 | /** |
||
206 | * @param string $title |
||
207 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
208 | */ |
||
209 | 5 | public function title(string $title): self |
|
215 | |||
216 | /** |
||
217 | * @param string $titleLink |
||
218 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
219 | */ |
||
220 | 1 | public function titleLink(string $titleLink): self |
|
226 | |||
227 | /** |
||
228 | * @param bool $titleLinkDownload |
||
229 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
230 | */ |
||
231 | 1 | public function titleLinkDownload(bool $titleLinkDownload): self |
|
237 | |||
238 | /** |
||
239 | * @param string $imageUrl |
||
240 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
241 | */ |
||
242 | 1 | public function imageUrl(string $imageUrl): self |
|
248 | |||
249 | /** |
||
250 | * @param string $audioUrl |
||
251 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
252 | */ |
||
253 | 1 | public function audioUrl(string $audioUrl): self |
|
259 | |||
260 | /** |
||
261 | * @param string $videoUrl |
||
262 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
263 | */ |
||
264 | 1 | public function videoUrl(string $videoUrl): self |
|
270 | |||
271 | /** |
||
272 | * @param array $fields |
||
273 | * @return \NotificationChannels\RocketChat\RocketChatAttachment |
||
274 | */ |
||
275 | 1 | public function fields(array $fields): self |
|
281 | |||
282 | /** |
||
283 | * Get an array representation of the RocketChatAttachment. |
||
284 | * |
||
285 | * @return array |
||
286 | */ |
||
287 | 25 | public function toArray(): array |
|
308 | |||
309 | /** |
||
310 | * Set attachment data from array. |
||
311 | * |
||
312 | * @param array $data |
||
313 | */ |
||
314 | 26 | private function setPropertiesFromArray(array $data) |
|
324 | } |
||
325 |