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 Array |
80
|
|
|
*/ |
81
|
|
|
private $mrkdwnIn; |
82
|
|
|
|
83
|
1 |
|
public function __construct() |
84
|
|
|
{ |
85
|
1 |
|
$this->fields = new ArrayCollection(); |
86
|
1 |
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @param string $title |
90
|
|
|
*/ |
91
|
1 |
|
public function setTitle($title) |
92
|
|
|
{ |
93
|
1 |
|
$this->title = $title; |
94
|
1 |
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @return string |
98
|
|
|
*/ |
99
|
1 |
|
public function getTitle() |
100
|
|
|
{ |
101
|
1 |
|
return $this->title; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @param string $titleLink |
106
|
|
|
*/ |
107
|
1 |
|
public function setTitleLink($titleLink) |
108
|
|
|
{ |
109
|
1 |
|
$this->titleLink = $titleLink; |
110
|
1 |
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* @return string |
114
|
|
|
*/ |
115
|
1 |
|
public function getTitleLink() |
116
|
|
|
{ |
117
|
1 |
|
return $this->titleLink; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* @param string $imageUrl |
122
|
|
|
*/ |
123
|
1 |
|
public function setImageUrl($imageUrl) |
124
|
|
|
{ |
125
|
1 |
|
$this->imageUrl = $imageUrl; |
126
|
1 |
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* @return string |
130
|
|
|
*/ |
131
|
1 |
|
public function getImageUrl() |
132
|
|
|
{ |
133
|
1 |
|
return $this->imageUrl; |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* @param string $authorName |
138
|
|
|
*/ |
139
|
1 |
|
public function setAuthorName($authorName) |
140
|
|
|
{ |
141
|
1 |
|
$this->authorName = $authorName; |
142
|
1 |
|
} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* @return string |
146
|
|
|
*/ |
147
|
1 |
|
public function getAuthorName() |
148
|
|
|
{ |
149
|
1 |
|
return $this->authorName; |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* @param string $authorLink |
154
|
|
|
*/ |
155
|
1 |
|
public function setAuthorLink($authorLink) |
156
|
|
|
{ |
157
|
1 |
|
$this->authorLink = $authorLink; |
158
|
1 |
|
} |
159
|
|
|
|
160
|
|
|
/** |
161
|
|
|
* @return string |
162
|
|
|
*/ |
163
|
1 |
|
public function getAuthorLink() |
164
|
|
|
{ |
165
|
1 |
|
return $this->authorLink; |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
/** |
169
|
|
|
* @param string $authorIcon |
170
|
|
|
*/ |
171
|
1 |
|
public function setAuthorIcon($authorIcon) |
172
|
|
|
{ |
173
|
1 |
|
$this->authorIcon = $authorIcon; |
174
|
1 |
|
} |
175
|
|
|
|
176
|
|
|
/** |
177
|
|
|
* @return string |
178
|
|
|
*/ |
179
|
1 |
|
public function getAuthorIcon() |
180
|
|
|
{ |
181
|
1 |
|
return $this->authorIcon; |
182
|
|
|
} |
183
|
|
|
|
184
|
|
|
/** |
185
|
|
|
* @param string $fallback Required text summary of the attachment that is shown by clients that understand attachments |
186
|
|
|
* but choose not to show them. |
187
|
|
|
*/ |
188
|
1 |
|
public function setFallback($fallback) |
189
|
|
|
{ |
190
|
1 |
|
$this->fallback = $fallback; |
191
|
1 |
|
} |
192
|
|
|
|
193
|
|
|
/** |
194
|
|
|
* @return string Text summary of the attachment that is shown by clients that understand attachments |
195
|
|
|
* but choose not to show them. |
196
|
|
|
*/ |
197
|
2 |
|
public function getFallback() |
198
|
|
|
{ |
199
|
2 |
|
return $this->fallback; |
200
|
|
|
} |
201
|
|
|
|
202
|
|
|
/** |
203
|
|
|
* @param string|null $preText Optional text that should appear above the formatted data. |
204
|
|
|
*/ |
205
|
1 |
|
public function setPreText($preText = null) |
206
|
|
|
{ |
207
|
1 |
|
$this->preText = $preText; |
208
|
1 |
|
} |
209
|
|
|
|
210
|
|
|
/** |
211
|
|
|
* @return string|null Optional text that should appear above the formatted data. |
212
|
|
|
*/ |
213
|
2 |
|
public function getPreText() |
214
|
|
|
{ |
215
|
2 |
|
return $this->preText; |
216
|
|
|
} |
217
|
|
|
|
218
|
|
|
/** |
219
|
|
|
* @param string|null $text Optional text that should appear within the attachment. |
220
|
|
|
*/ |
221
|
1 |
|
public function setText($text = null) |
222
|
|
|
{ |
223
|
1 |
|
$this->text = $text; |
224
|
1 |
|
} |
225
|
|
|
|
226
|
|
|
/** |
227
|
|
|
* @return string|null Optional text that should appear within the attachment. |
228
|
|
|
*/ |
229
|
2 |
|
public function getText() |
230
|
|
|
{ |
231
|
2 |
|
return $this->text; |
232
|
|
|
} |
233
|
|
|
|
234
|
|
|
/** |
235
|
|
|
* @param string|null $color Can either be one of 'good', 'warning', 'danger', or any hex color code |
236
|
|
|
*/ |
237
|
1 |
|
public function setColor($color = null) |
238
|
|
|
{ |
239
|
1 |
|
$this->color = $color; |
240
|
1 |
|
} |
241
|
|
|
|
242
|
|
|
/** |
243
|
|
|
* @return string|null Can either be one of 'good', 'warning', 'danger', or any hex color code |
244
|
|
|
*/ |
245
|
2 |
|
public function getColor() |
246
|
|
|
{ |
247
|
2 |
|
return $this->color; |
248
|
|
|
} |
249
|
|
|
|
250
|
|
|
/** |
251
|
|
|
* @param AttachmentField $field |
252
|
|
|
*/ |
253
|
1 |
|
public function addField(AttachmentField $field) |
254
|
|
|
{ |
255
|
1 |
|
$this->fields->add($field); |
256
|
1 |
|
} |
257
|
|
|
|
258
|
|
|
/** |
259
|
|
|
* @return AttachmentField[]|ArrayCollection |
260
|
|
|
*/ |
261
|
2 |
|
public function getFields() |
262
|
|
|
{ |
263
|
2 |
|
return $this->fields; |
264
|
|
|
} |
265
|
|
|
|
266
|
|
|
/** |
267
|
|
|
* @param array Valid values for mrkdwn_in are: ["pretext", "text", "fields"]. Setting "fields" will enable markup formatting for the value of each field |
268
|
|
|
*/ |
269
|
|
|
public function setMrkdwnIn(Array $mrkdwnIn) |
270
|
|
|
{ |
271
|
|
|
$this->mrkdwnIn = $mrkdwnIn; |
272
|
|
|
} |
273
|
|
|
|
274
|
|
|
/** |
275
|
|
|
* @return Array Valid values for mrkdwn_in are: ["pretext", "text", "fields"]. Setting "fields" will enable markup formatting for the value of each field |
276
|
|
|
*/ |
277
|
|
|
public function getMrkdwnIn() |
278
|
|
|
{ |
279
|
|
|
return $this->mrkdwnIn; |
280
|
|
|
} |
281
|
|
|
} |
282
|
|
|
|