1 | <?php |
||
15 | class Attachment |
||
16 | { |
||
17 | const COLOR_NOTICE = '#cccccc'; |
||
18 | const COLOR_INFO = '#5bc0de'; |
||
19 | const COLOR_GOOD = '#5cb85c'; |
||
20 | const COLOR_WARNING = '#f0ad4e'; |
||
21 | const COLOR_DANGER = '#d9534f'; |
||
22 | |||
23 | /** |
||
24 | * Required plain-text summary of the attachment. |
||
25 | * A plain-text summary of the attachment. This text will be used in clients that |
||
26 | * don't show formatted text (eg. IRC, mobile notifications) and should not contain |
||
27 | * any markup. |
||
28 | * |
||
29 | * @var string |
||
30 | */ |
||
31 | protected $fallback = ''; |
||
32 | |||
33 | /** |
||
34 | * Color for the attachment |
||
35 | * An optional value that can either be one of good, warning, danger, or |
||
36 | * any hex color code (eg. #439FE0). This value is used to color the border |
||
37 | * along the left side of the message attachment. |
||
38 | * |
||
39 | * @var string |
||
40 | */ |
||
41 | protected $color = self::COLOR_INFO; |
||
42 | |||
43 | /** |
||
44 | * This is optional text that appears above the message attachment block. |
||
45 | * |
||
46 | * @var string |
||
47 | */ |
||
48 | protected $pretext = ''; |
||
49 | |||
50 | /** |
||
51 | * Small text used to display the author's name. |
||
52 | * |
||
53 | * @var string |
||
54 | */ |
||
55 | protected $authorName = ''; |
||
56 | |||
57 | /** |
||
58 | * A valid URL that will hyperlink the author_name text mentioned above. |
||
59 | * Will only work if author_name is present. |
||
60 | * |
||
61 | * @var string |
||
62 | */ |
||
63 | protected $authorLink = ''; |
||
64 | |||
65 | /** |
||
66 | * A valid URL that displays a small 16x16px image to the left of the author_name text. |
||
67 | * Will only work if author_name is present. |
||
68 | * |
||
69 | * @var string |
||
70 | */ |
||
71 | protected $authorIcon = ''; |
||
72 | |||
73 | /** |
||
74 | * The title is displayed as larger, bold text near the top of a message attachment. |
||
75 | * |
||
76 | * @var string |
||
77 | */ |
||
78 | protected $title = ''; |
||
79 | |||
80 | /** |
||
81 | * By passing a valid URL in the title_link parameter (optional), the title text |
||
82 | * will be hyperlinked. |
||
83 | * |
||
84 | * @var string |
||
85 | */ |
||
86 | protected $titleLink = ''; |
||
87 | |||
88 | /** |
||
89 | * This is the main text in a message attachment, and can contain standard message |
||
90 | * markup. The content will automatically collapse if it contains 700+ characters |
||
91 | * or 5+ linebreaks, and will display a "Show more..." link to expand the content. |
||
92 | * |
||
93 | * @var string |
||
94 | */ |
||
95 | protected $text = ''; |
||
96 | |||
97 | /** |
||
98 | * Fields are defined as an array, and hashes contained within it will be displayed |
||
99 | * in a table inside the message attachment. |
||
100 | * |
||
101 | * @var array<\T3Bot\Slack\Message\Attachment\Field> |
||
102 | */ |
||
103 | protected $fields = []; |
||
104 | |||
105 | /** |
||
106 | * A valid URL to an image file that will be displayed inside a message attachment. |
||
107 | * We currently support the following formats: GIF, JPEG, PNG, and BMP. |
||
108 | * Large images will be resized to a maximum width of 400px or a maximum height of |
||
109 | * 500px, while still maintaining the original aspect ratio. |
||
110 | * |
||
111 | * @var string |
||
112 | */ |
||
113 | protected $imageUrl = ''; |
||
114 | |||
115 | /** |
||
116 | * A valid URL to an image file that will be displayed as a thumbnail on the right |
||
117 | * side of a message attachment. We currently support the following formats: GIF, |
||
118 | * JPEG, PNG, and BMP. |
||
119 | * The thumbnail's longest dimension will be scaled down to 75px while maintaining |
||
120 | * the aspect ratio of the image. The filesize of the image must also be less than |
||
121 | * 500 KB. |
||
122 | * |
||
123 | * @var string |
||
124 | */ |
||
125 | protected $thumbUrl = ''; |
||
126 | |||
127 | /** |
||
128 | * Constructor for an attachment. |
||
129 | * |
||
130 | * @param array $data |
||
131 | */ |
||
132 | 27 | public function __construct(array $data = []) |
|
140 | |||
141 | /** |
||
142 | * @return string |
||
143 | */ |
||
144 | 4 | public function getFallback() : string |
|
148 | |||
149 | /** |
||
150 | * @param string $fallback |
||
151 | */ |
||
152 | 27 | public function setFallback($fallback) |
|
156 | |||
157 | /** |
||
158 | * @return string |
||
159 | */ |
||
160 | 4 | public function getColor() : string |
|
164 | |||
165 | /** |
||
166 | * @param string $color |
||
167 | */ |
||
168 | 26 | public function setColor($color) |
|
172 | |||
173 | /** |
||
174 | * @return string |
||
175 | */ |
||
176 | 9 | public function getPretext() : string |
|
180 | |||
181 | /** |
||
182 | * @param string $pretext |
||
183 | */ |
||
184 | 12 | public function setPretext($pretext) |
|
185 | { |
||
186 | 12 | $this->pretext = $pretext; |
|
187 | 12 | } |
|
188 | |||
189 | /** |
||
190 | * @return string |
||
191 | */ |
||
192 | 4 | public function getAuthorName() : string |
|
196 | |||
197 | /** |
||
198 | * @param string $authorName |
||
199 | */ |
||
200 | 1 | public function setAuthorName($authorName) |
|
204 | |||
205 | /** |
||
206 | * @return string |
||
207 | */ |
||
208 | 4 | public function getAuthorLink() : string |
|
212 | |||
213 | /** |
||
214 | * @param string $authorLink |
||
215 | */ |
||
216 | 1 | public function setAuthorLink($authorLink) |
|
220 | |||
221 | /** |
||
222 | * @return string |
||
223 | */ |
||
224 | 4 | public function getAuthorIcon() : string |
|
228 | |||
229 | /** |
||
230 | * @param string $authorIcon |
||
231 | */ |
||
232 | 1 | public function setAuthorIcon($authorIcon) |
|
236 | |||
237 | /** |
||
238 | * @return string |
||
239 | */ |
||
240 | 10 | public function getTitle() : string |
|
244 | |||
245 | /** |
||
246 | * @param string $title |
||
247 | */ |
||
248 | 27 | public function setTitle($title) |
|
252 | |||
253 | /** |
||
254 | * @return string |
||
255 | */ |
||
256 | 4 | public function getTitleLink() : string |
|
260 | |||
261 | /** |
||
262 | * @param string $titleLink |
||
263 | */ |
||
264 | 13 | public function setTitleLink($titleLink) |
|
268 | |||
269 | /** |
||
270 | * @return string |
||
271 | */ |
||
272 | 4 | public function getText() : string |
|
276 | |||
277 | /** |
||
278 | * @param string $text |
||
279 | */ |
||
280 | 27 | public function setText($text) |
|
284 | |||
285 | /** |
||
286 | * @return string |
||
287 | */ |
||
288 | 4 | public function getImageUrl() : string |
|
292 | |||
293 | /** |
||
294 | * @param string $imageUrl |
||
295 | */ |
||
296 | 1 | public function setImageUrl($imageUrl) |
|
300 | |||
301 | /** |
||
302 | * @return string |
||
303 | */ |
||
304 | 4 | public function getThumbUrl() : string |
|
308 | |||
309 | /** |
||
310 | * @param string $thumbUrl |
||
311 | */ |
||
312 | 1 | public function setThumbUrl($thumbUrl) |
|
316 | } |
||
317 |