1 | <?php |
||
23 | class ChatPostMessagePayload extends AbstractPayload implements AdvancedSerializeInterface |
||
24 | { |
||
25 | /** |
||
26 | * @var string |
||
27 | */ |
||
28 | private $channel; |
||
29 | |||
30 | /** |
||
31 | * @var string |
||
32 | */ |
||
33 | private $text; |
||
34 | |||
35 | /** |
||
36 | * @var string |
||
37 | */ |
||
38 | private $username; |
||
39 | |||
40 | /** |
||
41 | * @var string |
||
42 | */ |
||
43 | private $iconEmoji; |
||
44 | |||
45 | /** |
||
46 | * @var string |
||
47 | */ |
||
48 | private $iconUrl; |
||
49 | |||
50 | /** |
||
51 | * @var bool |
||
52 | */ |
||
53 | private $unfurlLinks; |
||
54 | |||
55 | /** |
||
56 | * @var bool |
||
57 | */ |
||
58 | private $unfurlMedia; |
||
59 | |||
60 | /** |
||
61 | * @var bool |
||
62 | */ |
||
63 | private $linkNames; |
||
64 | |||
65 | /** |
||
66 | * @var string |
||
67 | */ |
||
68 | private $parse; |
||
69 | |||
70 | /** |
||
71 | * @var Attachment[]|ArrayCollection |
||
72 | */ |
||
73 | private $attachments; |
||
74 | |||
75 | /** |
||
76 | * @var string |
||
77 | */ |
||
78 | private $attachmentsJson; |
||
79 | |||
80 | 1 | public function __construct() |
|
84 | |||
85 | /** |
||
86 | * Sets the channel to send the message to. |
||
87 | * Can be a public channel, private group, IM channel, encoded ID, or a name. |
||
88 | * |
||
89 | * @param string $channel |
||
90 | */ |
||
91 | 1 | public function setChannel($channel) |
|
95 | |||
96 | /** |
||
97 | * @return string The channel to send the message to. |
||
98 | */ |
||
99 | 1 | public function getChannel() |
|
103 | |||
104 | /** |
||
105 | * @param string $text Actual message to send. |
||
106 | * |
||
107 | * @see https://api.slack.com/docs/formatting for an explanation of formatting. |
||
108 | */ |
||
109 | 1 | public function setText($text) |
|
113 | |||
114 | /** |
||
115 | * @return string Actual message to send. |
||
116 | */ |
||
117 | 1 | public function getText() |
|
121 | |||
122 | /** |
||
123 | * @param string $message |
||
124 | * |
||
125 | * @deprecated Will be removed soon, use `setText()` instead |
||
126 | */ |
||
127 | public function setMessage($message) |
||
131 | |||
132 | /** |
||
133 | * @return string |
||
134 | * |
||
135 | * @deprecated Will be removed soon, use `getText()` instead |
||
136 | */ |
||
137 | public function getMessage() |
||
141 | |||
142 | /** |
||
143 | * @param string $username Name of bot that will send the message (can be any name you want). |
||
144 | */ |
||
145 | 1 | public function setUsername($username) |
|
149 | |||
150 | /** |
||
151 | * @return string Name of the bot that will send the message. |
||
152 | */ |
||
153 | 1 | public function getUsername() |
|
157 | |||
158 | /** |
||
159 | * @param string $parse Change how messages are treated. |
||
160 | * |
||
161 | * @see https://api.slack.com/docs/formatting |
||
162 | */ |
||
163 | 1 | public function setParse($parse) |
|
167 | |||
168 | /** |
||
169 | * @return string Change how messages are treated. |
||
170 | */ |
||
171 | 1 | public function getParse() |
|
175 | |||
176 | /** |
||
177 | * Sets the emoji to use as the icon for this message (overrides icon URL). |
||
178 | * |
||
179 | * You can use one of Slack's emoji's or upload your own. |
||
180 | * |
||
181 | * @see https://{YOURSLACKTEAMHERE}.slack.com/customize/emoji |
||
182 | * |
||
183 | * @param string|null $iconEmoji Emoji to use as the icon for this message (overrides icon URL). |
||
184 | */ |
||
185 | 1 | public function setIconEmoji($iconEmoji) |
|
186 | { |
||
187 | 1 | if (substr($iconEmoji, 0, 1) !== ':') { |
|
188 | $iconEmoji = sprintf(':%s:', $iconEmoji); |
||
189 | } |
||
190 | |||
191 | 1 | $this->iconEmoji = $iconEmoji; |
|
192 | 1 | } |
|
193 | |||
194 | /** |
||
195 | * @return string|null Emoji to use as the icon for this message. |
||
196 | */ |
||
197 | 1 | public function getIconEmoji() |
|
201 | |||
202 | /** |
||
203 | * @param string|null $iconUrl URL to an image to use as the icon for this message. |
||
204 | */ |
||
205 | 1 | public function setIconUrl($iconUrl) |
|
209 | |||
210 | /** |
||
211 | * @return string|null URL to an image to use as the icon for this message. |
||
212 | */ |
||
213 | 1 | public function getIconUrl() |
|
217 | |||
218 | /** |
||
219 | * By default links to media are unfurled, but links to text content are not. |
||
220 | * For more information on the differences and how to control this, see the the unfurling documentation. |
||
221 | * |
||
222 | * @see https://api.slack.com/docs/unfurling |
||
223 | * |
||
224 | * @param bool $unfurlLinks Pass true to enable unfurling of primarily text-based content. |
||
225 | */ |
||
226 | 1 | public function setUnfurlLinks($unfurlLinks) |
|
230 | |||
231 | /** |
||
232 | * @return bool|null |
||
233 | */ |
||
234 | 1 | public function getUnfurlLinks() |
|
238 | |||
239 | /** |
||
240 | * @see https://api.slack.com/docs/unfurling |
||
241 | * |
||
242 | * @param bool $unfurlMedia Pass false to disable unfurling of media content. |
||
243 | */ |
||
244 | 1 | public function setUnfurlMedia($unfurlMedia) |
|
248 | |||
249 | /** |
||
250 | * @return bool|null |
||
251 | */ |
||
252 | 1 | public function getUnfurlMedia() |
|
256 | |||
257 | /** |
||
258 | * @param bool $linkNames Set to true to automatically find and link channel names and usernames in the message. |
||
259 | */ |
||
260 | 1 | public function setLinkNames($linkNames) |
|
264 | |||
265 | /** |
||
266 | * @see https://api.slack.com/docs/unfurling |
||
267 | * |
||
268 | * @return bool|null Whether channel names and usernames in the message should be linked automatically. |
||
269 | */ |
||
270 | 1 | public function getLinkNames() |
|
274 | |||
275 | /** |
||
276 | * @return Attachment[]|ArrayCollection |
||
277 | */ |
||
278 | 1 | public function getAttachments() |
|
282 | |||
283 | /** |
||
284 | * @param Attachment $attachment |
||
285 | */ |
||
286 | 1 | public function addAttachment(Attachment $attachment) |
|
290 | |||
291 | /** |
||
292 | * Use for serialization. |
||
293 | * |
||
294 | * @return string |
||
295 | */ |
||
296 | 1 | public function getAttachmentsJson() |
|
300 | |||
301 | /** |
||
302 | * {@inheritdoc} |
||
303 | */ |
||
304 | 1 | public function getMethod() |
|
308 | |||
309 | /** |
||
310 | * {@inheritdoc} |
||
311 | */ |
||
312 | 1 | public function beforeSerialize(Serializer $serializer) |
|
316 | } |
||
317 |