1 | <?php |
||
10 | class Attachment |
||
11 | { |
||
12 | const COLOR_GOOD = 'good'; |
||
13 | const COLOR_WARNING = 'warning'; |
||
14 | const COLOR_DANGER = 'danger'; |
||
15 | |||
16 | /** |
||
17 | * The fallback text to use for clients that don't support attachments. |
||
18 | * |
||
19 | * @var string |
||
20 | */ |
||
21 | protected $fallback; |
||
22 | |||
23 | /** |
||
24 | * Optional text that should appear within the attachment. |
||
25 | * |
||
26 | * @var string |
||
27 | */ |
||
28 | protected $text = ''; |
||
29 | |||
30 | /** |
||
31 | * Optional image that should appear within the attachment. |
||
32 | * |
||
33 | * @var string |
||
34 | */ |
||
35 | protected $imageUrl; |
||
36 | |||
37 | /** |
||
38 | * Optional thumbnail that should appear within the attachment. |
||
39 | * |
||
40 | * @var string |
||
41 | */ |
||
42 | protected $thumbUrl; |
||
43 | |||
44 | /** |
||
45 | * Optional text that should appear above the formatted data. |
||
46 | * |
||
47 | * @var string |
||
48 | */ |
||
49 | protected $preText; |
||
50 | |||
51 | /** |
||
52 | * Optional title for the attachment. |
||
53 | * |
||
54 | * @var string |
||
55 | */ |
||
56 | protected $title; |
||
57 | |||
58 | /** |
||
59 | * Optional title link for the attachment. |
||
60 | * |
||
61 | * @var string |
||
62 | */ |
||
63 | protected $titleLink; |
||
64 | |||
65 | /** |
||
66 | * Optional author name for the attachment. |
||
67 | * |
||
68 | * @var string |
||
69 | */ |
||
70 | protected $authorName; |
||
71 | |||
72 | /** |
||
73 | * Optional author link for the attachment. |
||
74 | * |
||
75 | * @var string |
||
76 | */ |
||
77 | protected $authorLink; |
||
78 | |||
79 | /** |
||
80 | * Optional author icon for the attachment. |
||
81 | * |
||
82 | * @var string |
||
83 | */ |
||
84 | protected $authorIcon; |
||
85 | |||
86 | /** |
||
87 | * The color to use for the attachment. |
||
88 | * |
||
89 | * @var string |
||
90 | */ |
||
91 | protected $color; |
||
92 | |||
93 | /** |
||
94 | * The text to use for the attachment footer. |
||
95 | * |
||
96 | * @var string |
||
97 | */ |
||
98 | protected $footer; |
||
99 | |||
100 | /** |
||
101 | * The icon to use for the attachment footer. |
||
102 | * |
||
103 | * @var string |
||
104 | */ |
||
105 | protected $footerIcon; |
||
106 | |||
107 | /** |
||
108 | * The timestamp to use for the attachment. |
||
109 | * |
||
110 | * @var \DateTime |
||
111 | */ |
||
112 | protected $timestamp; |
||
113 | |||
114 | /** |
||
115 | * The callback id to use for the attachment. |
||
116 | * |
||
117 | * @var string |
||
118 | */ |
||
119 | protected $callbackId; |
||
120 | |||
121 | /** |
||
122 | * The fields of the attachment. |
||
123 | * |
||
124 | * @var \Illuminate\Support\Collection |
||
125 | */ |
||
126 | protected $fields; |
||
127 | |||
128 | /** |
||
129 | * The actions of the attachment. |
||
130 | * |
||
131 | * @var \Illuminate\Support\Collection |
||
132 | */ |
||
133 | protected $actions; |
||
134 | |||
135 | public static function create() |
||
139 | |||
140 | public function __construct() |
||
146 | |||
147 | /** |
||
148 | * Set the fallback text. |
||
149 | * |
||
150 | * @param string $fallback |
||
151 | * |
||
152 | * @return $this |
||
153 | */ |
||
154 | public function setFallback(string $fallback) |
||
160 | |||
161 | /** |
||
162 | * Set the optional text to appear within the attachment. |
||
163 | * |
||
164 | * @param string $text |
||
165 | * |
||
166 | * @return $this |
||
167 | */ |
||
168 | public function setText($text) |
||
174 | |||
175 | /** |
||
176 | * Set the optional image to appear within the attachment. |
||
177 | * |
||
178 | * @param string $imageUrl |
||
179 | * |
||
180 | * @return $this |
||
181 | */ |
||
182 | public function setImageUrl(string $imageUrl) |
||
188 | |||
189 | /** |
||
190 | * Set the optional thumbnail to appear within the attachment. |
||
191 | * |
||
192 | * @param string $thumbUrl |
||
193 | * |
||
194 | * @return $this |
||
195 | */ |
||
196 | public function setThumbUrl(string $thumbUrl) |
||
202 | |||
203 | /** |
||
204 | * Set the text that should appear above the formatted data. |
||
205 | * |
||
206 | * @param string $preText |
||
207 | * |
||
208 | * @return $this |
||
209 | */ |
||
210 | public function setPreText(string $preText) |
||
216 | |||
217 | /** |
||
218 | * Set the color to use for the attachment. |
||
219 | * |
||
220 | * @param string $color |
||
221 | * |
||
222 | * @return $this |
||
223 | */ |
||
224 | public function setColor($color) |
||
230 | |||
231 | /** |
||
232 | * Set the footer text to use for the attachment. |
||
233 | * |
||
234 | * @param string $footer |
||
235 | * |
||
236 | * @return $this |
||
237 | */ |
||
238 | public function setFooter(string $footer) |
||
244 | |||
245 | /** |
||
246 | * Set the footer icon to use for the attachment. |
||
247 | * |
||
248 | * @param string $footerIcon |
||
249 | * |
||
250 | * @return $this |
||
251 | */ |
||
252 | public function setFooterIcon(string $footerIcon) |
||
258 | |||
259 | /** |
||
260 | * Set the timestamp to use for the attachment. |
||
261 | * |
||
262 | * @param \DateTime $timestamp |
||
263 | * |
||
264 | * @return $this |
||
265 | */ |
||
266 | public function setTimestamp(DateTime $timestamp) |
||
272 | |||
273 | /** |
||
274 | * Set the title to use for the attachment. |
||
275 | * |
||
276 | * @param string $title |
||
277 | * |
||
278 | * @return $this |
||
279 | */ |
||
280 | public function setTitle(string $title) |
||
286 | |||
287 | /** |
||
288 | * Set the title link to use for the attachment. |
||
289 | * |
||
290 | * @param string $titleLink |
||
291 | * |
||
292 | * @return $this |
||
293 | */ |
||
294 | public function setTitleLink(string $titleLink) |
||
300 | |||
301 | /** |
||
302 | * Set the author name to use for the attachment. |
||
303 | * |
||
304 | * @param string $authorName |
||
305 | * |
||
306 | * @return $this |
||
307 | */ |
||
308 | public function setAuthorName(string $authorName) |
||
314 | |||
315 | /** |
||
316 | * Set the auhtor link to use for the attachment. |
||
317 | * |
||
318 | * @param string $authorLink |
||
319 | * |
||
320 | * @return $this |
||
321 | */ |
||
322 | public function setAuthorLink(string $authorLink) |
||
328 | |||
329 | /** |
||
330 | * Set the author icon to use for the attachment. |
||
331 | * |
||
332 | * @param string $authorIcon |
||
333 | * |
||
334 | * @return $this |
||
335 | */ |
||
336 | public function setAuthorIcon(string $authorIcon) |
||
342 | |||
343 | /** |
||
344 | * Set the callback id to use for the attachment. |
||
345 | * |
||
346 | * @param string $callbackId |
||
347 | * |
||
348 | * @return $this |
||
349 | */ |
||
350 | public function setCallbackId(string $callbackId) |
||
356 | |||
357 | /** |
||
358 | * Add a field to the attachment. |
||
359 | * |
||
360 | * @param \Spatie\SlashCommand\AttachmentField|array $field |
||
361 | * |
||
362 | * @return $this |
||
363 | * |
||
364 | * @throws \Spatie\SlashCommand\Exceptions\FieldCannotBeAdded |
||
365 | */ |
||
366 | public function addField($field) |
||
383 | |||
384 | /** |
||
385 | * Add the fields for the attachment. |
||
386 | * |
||
387 | * @param array $fields |
||
388 | * |
||
389 | * @return $this |
||
390 | */ |
||
391 | public function addFields(array $fields) |
||
403 | |||
404 | /** |
||
405 | * Set the fields for the attachment. |
||
406 | * |
||
407 | * @param array $fields |
||
408 | * |
||
409 | * @return $this |
||
410 | */ |
||
411 | public function setFields(array $fields) |
||
419 | |||
420 | /** |
||
421 | * Clear all fields for this attachment. |
||
422 | * |
||
423 | * @return $this |
||
424 | */ |
||
425 | public function clearFields() |
||
431 | |||
432 | /** |
||
433 | * @param \Spatie\SlashCommand\AttachmentAction|array $action |
||
434 | * |
||
435 | * @return $this |
||
436 | * @throws \Spatie\SlashCommand\Exceptions\ActionCannotBeAdded |
||
437 | */ |
||
438 | public function addAction($action) |
||
456 | |||
457 | /** |
||
458 | * Add the actions for the attachment. |
||
459 | * |
||
460 | * @param array $actions |
||
461 | * |
||
462 | * @return $this |
||
463 | */ |
||
464 | public function addActions(array $actions) |
||
472 | |||
473 | /** |
||
474 | * Set the actions for the attachment. |
||
475 | * |
||
476 | * @param array $actions |
||
477 | * |
||
478 | * @return $this |
||
479 | */ |
||
480 | public function setActions(array $actions) |
||
488 | |||
489 | /** |
||
490 | * Clear all actions for this attachment. |
||
491 | * |
||
492 | * @return $this |
||
493 | */ |
||
494 | public function clearActions() |
||
500 | |||
501 | /** |
||
502 | * Convert this attachment to its array representation. |
||
503 | * |
||
504 | * @return array |
||
505 | */ |
||
506 | public function toArray() |
||
532 | } |
||
533 |