This repository has been archived by the owner on Jul 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
419 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php | ||
|
||
namespace DZunke\SlackBundle\Command; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
class UsersCommand extends ContainerAwareCommand | ||
{ | ||
|
||
protected function configure() | ||
{ | ||
$this | ||
->setName('dzunke:slack:users') | ||
->setAliases(['slack:users']) | ||
->setDescription('work with the users of your team') | ||
->addOption('only-active', 'a', InputOption::VALUE_NONE, 'lists only active users') | ||
->addOption('only-deleted', 'd', InputOption::VALUE_NONE, 'lists only deleted users') | ||
->addOption('user', 'u', InputOption::VALUE_REQUIRED, 'get a single user'); | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
$formatter = $this->getHelper('formatter'); | ||
|
||
try { | ||
$api = $this->getContainer()->get('dz.slack.users'); | ||
|
||
if ($input->getOption('only-active')) { | ||
$response = $api->getActiveUsers(); | ||
} elseif ($input->getOption('only-deleted')) { | ||
$response = $api->getDeletedUsers(); | ||
} elseif ($input->getOption('user')) { | ||
$response = $api->getUser($input->getOption('user')); | ||
|
||
if (is_array($response)) { | ||
$response = [$response['name'] => $response]; | ||
} | ||
} else { | ||
$response = $api->getUsers(); | ||
} | ||
|
||
if (empty($response)) { | ||
$output->writeln($formatter->formatBlock('✘ no data found', 'error')); | ||
return; | ||
} | ||
|
||
array_walk( | ||
$response, | ||
function (&$row) { | ||
foreach ($row as &$col) { | ||
if (is_bool($col)) { | ||
$col = $col ? 'true' : 'false'; | ||
} | ||
} | ||
} | ||
); | ||
|
||
$table = $this->getHelper('table'); | ||
$table->setHeaders(array_keys(reset($response)))->setRows($response); | ||
$table->render($output); | ||
|
||
|
||
} catch (\Exception $e) { | ||
$output->writeln( | ||
$formatter->formatBlock( | ||
sprintf('✘ there was an error with your request: "%s"', $e->getMessage()), | ||
'error' | ||
) | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
|
||
namespace DZunke\SlackBundle\Slack\Client\Actions; | ||
|
||
use DZunke\SlackBundle\Slack\Client\Actions; | ||
|
||
/** | ||
* @see https://api.slack.com/methods/channels.invite | ||
*/ | ||
class ChannelsInvite implements ActionsInterface | ||
{ | ||
|
||
/** | ||
* @var array | ||
*/ | ||
protected $parameter = [ | ||
'channel' => null, | ||
'user' => null | ||
]; | ||
|
||
/** | ||
* @return array | ||
* @throws \Exception | ||
*/ | ||
public function getRenderedRequestParams() | ||
{ | ||
if (is_null($this->parameter['channel']) || is_null($this->parameter['user'])) { | ||
throw new \Exception('both parameters channel and user must be given'); | ||
} | ||
|
||
return $this->parameter; | ||
} | ||
|
||
/** | ||
* @param array $parameter | ||
* @return $this | ||
*/ | ||
public function setParameter(array $parameter) | ||
{ | ||
foreach ($parameter as $key => $value) { | ||
if (array_key_exists($key, $this->parameter)) { | ||
$this->parameter[$key] = $value; | ||
} | ||
} | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getAction() | ||
{ | ||
return Actions::ACTION_CHANNELS_INVITE; | ||
} | ||
|
||
/** | ||
* @param array $response | ||
* @return array | ||
*/ | ||
public function parseResponse(array $response) | ||
{ | ||
return []; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.