|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Slack API library. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Cas Leentfaar <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace CL\Slack\Model; |
|
13
|
|
|
|
|
14
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* @author Cas Leentfaar <[email protected]> |
|
18
|
|
|
* |
|
19
|
|
|
* @link Official documentation at https://api.slack.com/docs/attachments |
|
20
|
|
|
*/ |
|
21
|
|
|
class Attachment extends AbstractModel |
|
22
|
|
|
{ |
|
23
|
|
|
/** |
|
24
|
|
|
* @var string |
|
25
|
|
|
*/ |
|
26
|
|
|
private $title; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @var string |
|
30
|
|
|
*/ |
|
31
|
|
|
private $titleLink; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @var string |
|
35
|
|
|
*/ |
|
36
|
|
|
private $imageUrl; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @var string |
|
40
|
|
|
*/ |
|
41
|
|
|
private $authorName; |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @var string |
|
45
|
|
|
*/ |
|
46
|
|
|
private $authorLink; |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @var string |
|
50
|
|
|
*/ |
|
51
|
|
|
private $authorIcon; |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @var string |
|
55
|
|
|
*/ |
|
56
|
|
|
private $preText; |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* @var string |
|
60
|
|
|
*/ |
|
61
|
|
|
private $text; |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* @var string |
|
65
|
|
|
*/ |
|
66
|
|
|
private $color; |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* @var string |
|
70
|
|
|
*/ |
|
71
|
|
|
private $fallback; |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* @var AttachmentField[]|ArrayCollection |
|
75
|
|
|
*/ |
|
76
|
|
|
private $fields; |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* @var AttachmentAction[]|ArrayCollection |
|
80
|
|
|
*/ |
|
81
|
|
|
private $actions; |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* @var Array |
|
85
|
|
|
*/ |
|
86
|
|
|
private $mrkdwnIn; |
|
87
|
|
|
|
|
88
|
1 |
|
public function __construct() |
|
89
|
|
|
{ |
|
90
|
1 |
|
$this->fields = new ArrayCollection(); |
|
91
|
1 |
|
$this->actions = new ArrayCollection(); |
|
92
|
1 |
|
} |
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* @param string $title |
|
96
|
|
|
*/ |
|
97
|
1 |
|
public function setTitle($title) |
|
98
|
|
|
{ |
|
99
|
1 |
|
$this->title = $title; |
|
100
|
1 |
|
} |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* @return string |
|
104
|
|
|
*/ |
|
105
|
1 |
|
public function getTitle() |
|
106
|
|
|
{ |
|
107
|
1 |
|
return $this->title; |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
/** |
|
111
|
|
|
* @param string $titleLink |
|
112
|
|
|
*/ |
|
113
|
1 |
|
public function setTitleLink($titleLink) |
|
114
|
|
|
{ |
|
115
|
1 |
|
$this->titleLink = $titleLink; |
|
116
|
1 |
|
} |
|
117
|
|
|
|
|
118
|
|
|
/** |
|
119
|
|
|
* @return string |
|
120
|
|
|
*/ |
|
121
|
1 |
|
public function getTitleLink() |
|
122
|
|
|
{ |
|
123
|
1 |
|
return $this->titleLink; |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
/** |
|
127
|
|
|
* @param string $imageUrl |
|
128
|
|
|
*/ |
|
129
|
1 |
|
public function setImageUrl($imageUrl) |
|
130
|
|
|
{ |
|
131
|
1 |
|
$this->imageUrl = $imageUrl; |
|
132
|
1 |
|
} |
|
133
|
|
|
|
|
134
|
|
|
/** |
|
135
|
|
|
* @return string |
|
136
|
|
|
*/ |
|
137
|
1 |
|
public function getImageUrl() |
|
138
|
|
|
{ |
|
139
|
1 |
|
return $this->imageUrl; |
|
140
|
|
|
} |
|
141
|
|
|
|
|
142
|
|
|
/** |
|
143
|
|
|
* @param string $authorName |
|
144
|
|
|
*/ |
|
145
|
1 |
|
public function setAuthorName($authorName) |
|
146
|
|
|
{ |
|
147
|
1 |
|
$this->authorName = $authorName; |
|
148
|
1 |
|
} |
|
149
|
|
|
|
|
150
|
|
|
/** |
|
151
|
|
|
* @return string |
|
152
|
|
|
*/ |
|
153
|
1 |
|
public function getAuthorName() |
|
154
|
|
|
{ |
|
155
|
1 |
|
return $this->authorName; |
|
156
|
|
|
} |
|
157
|
|
|
|
|
158
|
|
|
/** |
|
159
|
|
|
* @param string $authorLink |
|
160
|
|
|
*/ |
|
161
|
1 |
|
public function setAuthorLink($authorLink) |
|
162
|
|
|
{ |
|
163
|
1 |
|
$this->authorLink = $authorLink; |
|
164
|
1 |
|
} |
|
165
|
|
|
|
|
166
|
|
|
/** |
|
167
|
|
|
* @return string |
|
168
|
|
|
*/ |
|
169
|
1 |
|
public function getAuthorLink() |
|
170
|
|
|
{ |
|
171
|
1 |
|
return $this->authorLink; |
|
172
|
|
|
} |
|
173
|
|
|
|
|
174
|
|
|
/** |
|
175
|
|
|
* @param string $authorIcon |
|
176
|
|
|
*/ |
|
177
|
1 |
|
public function setAuthorIcon($authorIcon) |
|
178
|
|
|
{ |
|
179
|
1 |
|
$this->authorIcon = $authorIcon; |
|
180
|
1 |
|
} |
|
181
|
|
|
|
|
182
|
|
|
/** |
|
183
|
|
|
* @return string |
|
184
|
|
|
*/ |
|
185
|
1 |
|
public function getAuthorIcon() |
|
186
|
|
|
{ |
|
187
|
1 |
|
return $this->authorIcon; |
|
188
|
|
|
} |
|
189
|
|
|
|
|
190
|
|
|
/** |
|
191
|
|
|
* @param string $fallback Required text summary of the attachment that is shown by clients that understand attachments |
|
192
|
|
|
* but choose not to show them. |
|
193
|
|
|
*/ |
|
194
|
1 |
|
public function setFallback($fallback) |
|
195
|
|
|
{ |
|
196
|
1 |
|
$this->fallback = $fallback; |
|
197
|
1 |
|
} |
|
198
|
|
|
|
|
199
|
|
|
/** |
|
200
|
|
|
* @return string Text summary of the attachment that is shown by clients that understand attachments |
|
201
|
|
|
* but choose not to show them. |
|
202
|
|
|
*/ |
|
203
|
2 |
|
public function getFallback() |
|
204
|
|
|
{ |
|
205
|
2 |
|
return $this->fallback; |
|
206
|
|
|
} |
|
207
|
|
|
|
|
208
|
|
|
/** |
|
209
|
|
|
* @param string|null $preText Optional text that should appear above the formatted data. |
|
210
|
|
|
*/ |
|
211
|
1 |
|
public function setPreText($preText = null) |
|
212
|
|
|
{ |
|
213
|
1 |
|
$this->preText = $preText; |
|
214
|
1 |
|
} |
|
215
|
|
|
|
|
216
|
|
|
/** |
|
217
|
|
|
* @return string|null Optional text that should appear above the formatted data. |
|
218
|
|
|
*/ |
|
219
|
2 |
|
public function getPreText() |
|
220
|
|
|
{ |
|
221
|
2 |
|
return $this->preText; |
|
222
|
|
|
} |
|
223
|
|
|
|
|
224
|
|
|
/** |
|
225
|
|
|
* @param string|null $text Optional text that should appear within the attachment. |
|
226
|
|
|
*/ |
|
227
|
1 |
|
public function setText($text = null) |
|
228
|
|
|
{ |
|
229
|
1 |
|
$this->text = $text; |
|
230
|
1 |
|
} |
|
231
|
|
|
|
|
232
|
|
|
/** |
|
233
|
|
|
* @return string|null Optional text that should appear within the attachment. |
|
234
|
|
|
*/ |
|
235
|
2 |
|
public function getText() |
|
236
|
|
|
{ |
|
237
|
2 |
|
return $this->text; |
|
238
|
|
|
} |
|
239
|
|
|
|
|
240
|
|
|
/** |
|
241
|
|
|
* @param string|null $color Can either be one of 'good', 'warning', 'danger', or any hex color code |
|
242
|
|
|
*/ |
|
243
|
1 |
|
public function setColor($color = null) |
|
244
|
|
|
{ |
|
245
|
1 |
|
$this->color = $color; |
|
246
|
1 |
|
} |
|
247
|
|
|
|
|
248
|
|
|
/** |
|
249
|
|
|
* @return string|null Can either be one of 'good', 'warning', 'danger', or any hex color code |
|
250
|
|
|
*/ |
|
251
|
2 |
|
public function getColor() |
|
252
|
|
|
{ |
|
253
|
2 |
|
return $this->color; |
|
254
|
|
|
} |
|
255
|
|
|
|
|
256
|
|
|
/** |
|
257
|
|
|
* @param AttachmentField $field |
|
258
|
|
|
*/ |
|
259
|
1 |
|
public function addField(AttachmentField $field) |
|
260
|
|
|
{ |
|
261
|
1 |
|
$this->fields->add($field); |
|
262
|
1 |
|
} |
|
263
|
|
|
|
|
264
|
|
|
/** |
|
265
|
|
|
* @return AttachmentField[]|ArrayCollection |
|
266
|
|
|
*/ |
|
267
|
2 |
|
public function getFields() |
|
268
|
|
|
{ |
|
269
|
2 |
|
return $this->fields; |
|
270
|
|
|
} |
|
271
|
|
|
|
|
272
|
|
|
/** |
|
273
|
|
|
* @param array Valid values for mrkdwn_in are: ["pretext", "text", "fields"]. Setting "fields" will enable markup formatting for the value of each field |
|
274
|
|
|
*/ |
|
275
|
|
|
public function setMrkdwnIn(Array $mrkdwnIn) |
|
276
|
|
|
{ |
|
277
|
|
|
$this->mrkdwnIn = $mrkdwnIn; |
|
278
|
|
|
} |
|
279
|
|
|
|
|
280
|
|
|
/** |
|
281
|
|
|
* @return Array Valid values for mrkdwn_in are: ["pretext", "text", "fields"]. Setting "fields" will enable markup formatting for the value of each field |
|
282
|
|
|
*/ |
|
283
|
|
|
public function getMrkdwnIn() |
|
284
|
|
|
{ |
|
285
|
|
|
return $this->mrkdwnIn; |
|
286
|
|
|
} |
|
287
|
|
|
|
|
288
|
|
|
|
|
289
|
|
|
/** |
|
290
|
|
|
* @param AttachmentAction $action |
|
291
|
|
|
*/ |
|
292
|
1 |
|
public function addAction(AttachmentAction $action) |
|
293
|
|
|
{ |
|
294
|
1 |
|
$this->actions->add($action); |
|
295
|
1 |
|
} |
|
296
|
|
|
|
|
297
|
|
|
/** |
|
298
|
|
|
* @return AttachmentAction[]|ArrayCollection |
|
299
|
|
|
*/ |
|
300
|
2 |
|
public function getActions() |
|
301
|
|
|
{ |
|
302
|
2 |
|
return $this->actions; |
|
303
|
|
|
} |
|
304
|
|
|
|
|
305
|
|
|
} |
|
306
|
|
|
|