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 setactivermation, 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\UsersSetActivePayload; |
15
|
|
|
use CL\Slack\Payload\UsersSetActivePayloadResponse; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @author Cas Leentfaar <[email protected]> |
19
|
|
|
*/ |
20
|
|
|
class UsersSetActiveCommand extends AbstractApiCommand |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* {@inheritDoc} |
24
|
|
|
*/ |
25
|
|
|
protected function configure() |
26
|
|
|
{ |
27
|
|
|
parent::configure(); |
28
|
|
|
|
29
|
|
|
$this->setName('users:set-active'); |
30
|
|
|
$this->setDescription('Lets the slack messaging server know that the token\'s user is currently active'); |
31
|
|
|
$this->setHelp(<<<EOT |
32
|
|
|
The <info>users:set-active</info> command lets the slack messaging server know that the token's |
33
|
|
|
user is currently active. Consult the presence documentation for more details (see link below). |
34
|
|
|
|
35
|
|
|
For more information about the related API method, check out the official documentation: |
36
|
|
|
<comment>https://api.slack.com/methods/users.setActive</comment> |
37
|
|
|
EOT |
38
|
|
|
); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @return UsersSetActivePayload |
43
|
|
|
*/ |
44
|
|
|
protected function createPayload() |
45
|
|
|
{ |
46
|
|
|
$payload = new UsersSetActivePayload(); |
47
|
|
|
|
48
|
|
|
return $payload; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* {@inheritdoc} |
53
|
|
|
* |
54
|
|
|
* @param UsersSetActivePayloadResponse $payloadResponse |
55
|
|
|
*/ |
56
|
|
|
protected function handleResponse($payloadResponse) |
57
|
|
|
{ |
58
|
|
|
if ($payloadResponse->isOk()) { |
59
|
|
|
$this->writeOk('Successfully informed Slack of the token user\'s active status'); |
60
|
|
|
} else { |
61
|
|
|
$this->writeError(sprintf( |
62
|
|
|
'Failed to set the user to active: %s', |
63
|
|
|
lcfirst($payloadResponse->getErrorExplanation()) |
64
|
|
|
)); |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|