1 | <?php |
||
9 | class Attachment |
||
10 | { |
||
11 | const COLOR_GOOD = 'good'; |
||
12 | const COLOR_WARNING = 'warning'; |
||
13 | const COLOR_DANGER = 'danger'; |
||
14 | |||
15 | /** |
||
16 | * The fallback text to use for clients that don't support attachments. |
||
17 | * |
||
18 | * @var string |
||
19 | */ |
||
20 | protected $fallback; |
||
21 | |||
22 | /** |
||
23 | * Optional text that should appear within the attachment. |
||
24 | * |
||
25 | * @var string |
||
26 | */ |
||
27 | protected $text = ''; |
||
28 | |||
29 | /** |
||
30 | * Optional image that should appear within the attachment. |
||
31 | * |
||
32 | * @var string |
||
33 | */ |
||
34 | protected $imageUrl; |
||
35 | |||
36 | /** |
||
37 | * Optional thumbnail that should appear within the attachment. |
||
38 | * |
||
39 | * @var string |
||
40 | */ |
||
41 | protected $thumbUrl; |
||
42 | |||
43 | /** |
||
44 | * Optional text that should appear above the formatted data. |
||
45 | * |
||
46 | * @var string |
||
47 | */ |
||
48 | protected $preText; |
||
49 | |||
50 | /** |
||
51 | * Optional title for the attachment. |
||
52 | * |
||
53 | * @var string |
||
54 | */ |
||
55 | protected $title; |
||
56 | |||
57 | /** |
||
58 | * Optional title link for the attachment. |
||
59 | * |
||
60 | * @var string |
||
61 | */ |
||
62 | protected $titleLink; |
||
63 | |||
64 | /** |
||
65 | * Optional author name for the attachment. |
||
66 | * |
||
67 | * @var string |
||
68 | */ |
||
69 | protected $authorName; |
||
70 | |||
71 | /** |
||
72 | * Optional author link for the attachment. |
||
73 | * |
||
74 | * @var string |
||
75 | */ |
||
76 | protected $authorLink; |
||
77 | |||
78 | /** |
||
79 | * Optional author icon for the attachment. |
||
80 | * |
||
81 | * @var string |
||
82 | */ |
||
83 | protected $authorIcon; |
||
84 | |||
85 | /** |
||
86 | * The color to use for the attachment. |
||
87 | * |
||
88 | * @var string |
||
89 | */ |
||
90 | protected $color; |
||
91 | |||
92 | /** |
||
93 | * The text to use for the attachment footer. |
||
94 | * |
||
95 | * @var string |
||
96 | */ |
||
97 | protected $footer; |
||
98 | |||
99 | /** |
||
100 | * The icon to use for the attachment footer. |
||
101 | * |
||
102 | * @var string |
||
103 | */ |
||
104 | protected $footerIcon; |
||
105 | |||
106 | /** |
||
107 | * The timestamp to use for the attachment. |
||
108 | * |
||
109 | * @var \DateTime |
||
110 | */ |
||
111 | protected $timestamp; |
||
112 | |||
113 | /** |
||
114 | * The fields of the attachment. |
||
115 | * |
||
116 | * @var Collection |
||
117 | */ |
||
118 | protected $fields; |
||
119 | |||
120 | |||
121 | public static function create() |
||
125 | |||
126 | public function __construct() |
||
130 | |||
131 | /** |
||
132 | * Get the fallback text. |
||
133 | * |
||
134 | * @return string |
||
135 | */ |
||
136 | public function getFallback() |
||
140 | |||
141 | /** |
||
142 | * Set the fallback text. |
||
143 | * |
||
144 | * @param string $fallback |
||
145 | * |
||
146 | * @return $this |
||
147 | */ |
||
148 | public function setFallback(string $fallback) |
||
154 | |||
155 | /** |
||
156 | * Get the optional text to appear within the attachment. |
||
157 | * |
||
158 | * @return string |
||
159 | */ |
||
160 | public function getText(): string |
||
164 | |||
165 | /** |
||
166 | * Set the optional text to appear within the attachment. |
||
167 | * |
||
168 | * @param string $text |
||
169 | * |
||
170 | * @return $this |
||
171 | */ |
||
172 | public function setText($text) |
||
178 | |||
179 | /** |
||
180 | * Get the optional image to appear within the attachment. |
||
181 | * |
||
182 | * @return string |
||
183 | */ |
||
184 | public function getImageUrl(): string |
||
188 | |||
189 | /** |
||
190 | * Set the optional image to appear within the attachment. |
||
191 | * |
||
192 | * @param string $imageUrl |
||
193 | * |
||
194 | * @return $this |
||
195 | */ |
||
196 | public function setImageUrl(string $imageUrl) |
||
202 | |||
203 | /** |
||
204 | * Get the optional thumbnail to appear within the attachment. |
||
205 | * |
||
206 | * @return string |
||
207 | */ |
||
208 | public function getThumbUrl(): string |
||
212 | |||
213 | /** |
||
214 | * Set the optional thumbnail to appear within the attachment. |
||
215 | * |
||
216 | * @param string $thumbUrl |
||
217 | * |
||
218 | * @return $this |
||
219 | */ |
||
220 | public function setThumbUrl(string $thumbUrl) |
||
226 | |||
227 | /** |
||
228 | * Get the text that should appear above the formatted data. |
||
229 | * |
||
230 | * @return string |
||
231 | */ |
||
232 | public function getPreText(): string |
||
236 | |||
237 | /** |
||
238 | * Set the text that should appear above the formatted data. |
||
239 | * |
||
240 | * @param string $preText |
||
241 | * |
||
242 | * @return $this |
||
243 | */ |
||
244 | public function setPreText(string $preText) |
||
250 | |||
251 | /** |
||
252 | * Get the color to use for the attachment. |
||
253 | * |
||
254 | * @return string |
||
255 | */ |
||
256 | public function getColor(): string |
||
260 | |||
261 | /** |
||
262 | * Set the color to use for the attachment. |
||
263 | * |
||
264 | * @param string $color |
||
265 | * |
||
266 | * @return $this |
||
267 | */ |
||
268 | public function setColor($color) |
||
274 | |||
275 | /** |
||
276 | * Get the footer to use for the attachment. |
||
277 | * |
||
278 | * @return string |
||
279 | */ |
||
280 | public function getFooter(): string |
||
284 | |||
285 | /** |
||
286 | * Set the footer text to use for the attachment. |
||
287 | * |
||
288 | * @param string $footer |
||
289 | * @return $this |
||
290 | */ |
||
291 | public function setFooter(string $footer) |
||
297 | |||
298 | /** |
||
299 | * Get the footer icon to use for the attachment. |
||
300 | * |
||
301 | * @return string |
||
302 | */ |
||
303 | public function getFooterIcon(): string |
||
307 | |||
308 | /** |
||
309 | * Set the footer icon to use for the attachment. |
||
310 | * |
||
311 | * @param string $footerIcon |
||
312 | * |
||
313 | * @return $this |
||
314 | */ |
||
315 | public function setFooterIcon(string $footerIcon) |
||
321 | |||
322 | /** |
||
323 | * Get the timestamp to use for the attachment. |
||
324 | * |
||
325 | * @return \DateTime |
||
326 | */ |
||
327 | public function getTimestamp(): DateTime |
||
331 | |||
332 | /** |
||
333 | * Set the timestamp to use for the attachment. |
||
334 | * |
||
335 | * @param \DateTime $timestamp |
||
336 | * @return $this |
||
337 | */ |
||
338 | public function setTimestamp(DateTime $timestamp) |
||
344 | |||
345 | /** |
||
346 | * Get the title to use for the attachment. |
||
347 | * |
||
348 | * @return string |
||
349 | */ |
||
350 | public function getTitle(): string |
||
354 | |||
355 | /** |
||
356 | * Set the title to use for the attachment. |
||
357 | * |
||
358 | * @param string $title |
||
359 | * @return $this |
||
360 | */ |
||
361 | public function setTitle(string $title) |
||
367 | |||
368 | /** |
||
369 | * Get the title link to use for the attachment. |
||
370 | * |
||
371 | * @return string |
||
372 | */ |
||
373 | public function getTitleLink(): string |
||
377 | |||
378 | /** |
||
379 | * Set the title link to use for the attachment. |
||
380 | * |
||
381 | * @param string $titleLink |
||
382 | * @return $this |
||
383 | */ |
||
384 | public function setTitleLink(string $titleLink) |
||
390 | |||
391 | /** |
||
392 | * Get the author name to use for the attachment. |
||
393 | * |
||
394 | * @return string |
||
395 | */ |
||
396 | public function getAuthorName(): string |
||
400 | |||
401 | /** |
||
402 | * Set the author name to use for the attachment. |
||
403 | * |
||
404 | * @param string $authorName |
||
405 | * @return $this |
||
406 | */ |
||
407 | public function setAuthorName(string $authorName) |
||
413 | |||
414 | /** |
||
415 | * Get the author link to use for the attachment. |
||
416 | * |
||
417 | * @return string |
||
418 | */ |
||
419 | public function getAuthorLink(): string |
||
423 | |||
424 | /** |
||
425 | * Set the auhtor link to use for the attachment. |
||
426 | * |
||
427 | * @param string $authorLink |
||
428 | * @return $this |
||
429 | */ |
||
430 | public function setAuthorLink(string $authorLink) |
||
436 | |||
437 | /** |
||
438 | * Get the author icon to use for the attachment. |
||
439 | * |
||
440 | * @return string |
||
441 | */ |
||
442 | public function getAuthorIcon(): string |
||
446 | |||
447 | /** |
||
448 | * Set the author icon to use for the attachment. |
||
449 | * |
||
450 | * @param string $authorIcon |
||
451 | * @return $this |
||
452 | */ |
||
453 | public function setAuthorIcon(string $authorIcon) |
||
459 | |||
460 | /** |
||
461 | * Get the fields for the attachment. |
||
462 | * |
||
463 | * @return array |
||
464 | */ |
||
465 | public function getFields(): array |
||
469 | |||
470 | /** |
||
471 | * Set the fields for the attachment. |
||
472 | * |
||
473 | * @param array $fields |
||
474 | * @return $this |
||
475 | */ |
||
476 | public function setFields(array $fields) |
||
486 | |||
487 | /** |
||
488 | * Add a field to the attachment. |
||
489 | * |
||
490 | * @param \Spatie\SlashCommand\AttachmentField|array $field |
||
491 | * |
||
492 | * @return $this |
||
493 | * @throws \Spatie\SlashCommand\Exceptions\FieldCannotBeAdded |
||
494 | */ |
||
495 | public function addField($field) |
||
509 | |||
510 | /** |
||
511 | * Clear all fields for this attachment. |
||
512 | * |
||
513 | * @return $this |
||
514 | */ |
||
515 | public function clearFields() |
||
521 | |||
522 | /** |
||
523 | * Convert this attachment to its array representation. |
||
524 | * |
||
525 | * @return array |
||
526 | */ |
||
527 | public function toArray() |
||
549 | } |