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\GroupsArchivePayload; |
15
|
|
|
use CL\Slack\Payload\GroupsArchivePayloadResponse; |
16
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @author Cas Leentfaar <[email protected]> |
20
|
|
|
*/ |
21
|
|
|
class GroupsArchiveCommand extends AbstractApiCommand |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* {@inheritDoc} |
25
|
|
|
*/ |
26
|
|
|
protected function configure() |
27
|
|
|
{ |
28
|
|
|
parent::configure(); |
29
|
|
|
|
30
|
|
|
$this->setName('groups:archive'); |
31
|
|
|
$this->setDescription('Archives a given Slack group'); |
32
|
|
|
$this->addArgument('group-id', InputArgument::REQUIRED, 'The ID of a private group to archive'); |
33
|
|
|
$this->setHelp(<<<EOT |
34
|
|
|
The <info>groups:archive</info> command let's you archive a given Slack group. |
35
|
|
|
|
36
|
|
|
For more information about the related API method, check out the official documentation: |
37
|
|
|
<comment>https://api.slack.com/methods/groups.archive</comment> |
38
|
|
|
EOT |
39
|
|
|
); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @return GroupsArchivePayload |
44
|
|
|
*/ |
45
|
|
|
protected function createPayload() |
46
|
|
|
{ |
47
|
|
|
$payload = new GroupsArchivePayload(); |
48
|
|
|
$payload->setGroupId($this->input->getArgument('group-id')); |
49
|
|
|
|
50
|
|
|
return $payload; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* {@inheritdoc} |
55
|
|
|
* |
56
|
|
|
* @param GroupsArchivePayloadResponse $payloadResponse |
57
|
|
|
*/ |
58
|
|
|
protected function handleResponse($payloadResponse) |
59
|
|
|
{ |
60
|
|
|
if ($payloadResponse->isOk()) { |
61
|
|
|
$this->writeOk('Successfully archived group!'); |
62
|
|
|
} else { |
63
|
|
|
$this->writeError(sprintf('Failed to archive group: %s', lcfirst($payloadResponse->getErrorExplanation()))); |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|