|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the slack-cli package. |
|
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\SlackCli\Command; |
|
13
|
|
|
|
|
14
|
|
|
use CL\Slack\Payload\EmojiListPayload; |
|
15
|
|
|
use CL\Slack\Payload\EmojiListPayloadResponse; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* @author Cas Leentfaar <[email protected]> |
|
19
|
|
|
*/ |
|
20
|
|
|
class EmojiListCommand extends AbstractApiCommand |
|
21
|
|
|
{ |
|
22
|
|
|
/** |
|
23
|
|
|
* {@inheritDoc} |
|
24
|
|
|
*/ |
|
25
|
|
|
protected function configure() |
|
26
|
|
|
{ |
|
27
|
|
|
parent::configure(); |
|
28
|
|
|
|
|
29
|
|
|
$this->setName('emoji:list'); |
|
30
|
|
|
$this->setDescription('Returns a list of all the custom emoji for your Slack team'); |
|
31
|
|
|
$this->setHelp(<<<EOT |
|
32
|
|
|
The <info>emoji:list</info> command returns a list of all the custom emoji in your Slack team. |
|
33
|
|
|
|
|
34
|
|
|
The emoji property contains a map of name/url pairs, one for each custom emoji used by the team. |
|
35
|
|
|
|
|
36
|
|
|
The alias: <comment>pseudo-protocol</comment> will be used where the emoji is an alias, the string following the colon is |
|
37
|
|
|
the name of the other emoji this emoji is an alias to. |
|
38
|
|
|
|
|
39
|
|
|
For more information about the related API method, check out the official documentation: |
|
40
|
|
|
<comment>https://api.slack.com/methods/emoji.list</comment> |
|
41
|
|
|
EOT |
|
42
|
|
|
); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @return EmojiListPayload |
|
47
|
|
|
*/ |
|
48
|
|
|
protected function createPayload() |
|
49
|
|
|
{ |
|
50
|
|
|
$payload = new EmojiListPayload(); |
|
51
|
|
|
|
|
52
|
|
|
return $payload; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* {@inheritdoc} |
|
57
|
|
|
* |
|
58
|
|
|
* @param EmojiListPayloadResponse $payloadResponse |
|
59
|
|
|
*/ |
|
60
|
|
|
protected function handleResponse($payloadResponse) |
|
61
|
|
|
{ |
|
62
|
|
|
if ($payloadResponse->isOk()) { |
|
63
|
|
|
$emojis = $payloadResponse->getEmojis(); |
|
64
|
|
|
$this->output->writeln(sprintf('Got <comment>%d</comment> emojis...', count($emojis))); |
|
65
|
|
|
if (!empty($emojis)) { |
|
66
|
|
|
$this->renderKeyValueTable($emojis, ['Name', 'URL']); |
|
67
|
|
|
} |
|
68
|
|
|
} else { |
|
69
|
|
|
$this->writeError(sprintf('Failed to fetch emojis: %s', lcfirst($payloadResponse->getErrorExplanation()))); |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
|