-
Notifications
You must be signed in to change notification settings - Fork 1
Home
Jose Maria Valera Reales edited this page Dec 2, 2019
·
17 revisions
Welcome to the ScrumMaster wiki!
Here you can see an implementation example using the NotifierCommand
with multiple channels (Slack and Email).
declare(strict_types=1);
require dirname(__DIR__) . '/../vendor/autoload.php';
use Chemaclass\ScrumMaster\Channel\Email;
use Chemaclass\ScrumMaster\Channel\Slack;
use Chemaclass\ScrumMaster\Command\IO\EchoOutput;
use Chemaclass\ScrumMaster\Command\NotifierCommand;
use Chemaclass\ScrumMaster\Command\NotifierInput;
use Chemaclass\ScrumMaster\Command\NotifierOutput;
use Chemaclass\ScrumMaster\Jira\JiraHttpClient;
use Symfony\Component\HttpClient\HttpClient;
use Symfony\Component\Mailer\Bridge\Google\Transport\GmailSmtpTransport;
use Symfony\Component\Mailer\Mailer;
$jiraHttpClient = new JiraHttpClient(HttpClient::create([
'auth_basic' => ['JIRA_API_LABEL', 'JIRA_API_PASSWORD'],
]));
$channels = [
new Slack\Channel(
new Slack\HttpClient(HttpClient::create([
'auth_bearer' => 'SLACK_BOT_USER_OAUTH_ACCESS_TOKEN',
])),
Slack\JiraMapping::jiraNameWithSlackId([
'fallback' => 'slack.group.id',
'jira.person.id' => 'slack.member.id',
]),
Slack\MessageGenerator::withTimeToDiff(new DateTimeImmutable())
),
new Email\Channel(
new Mailer(new GmailSmtpTransport('USERNAME@MAILER.COM', 'MAILER_PASSWORD')),
Email\MessageGenerator::withTimeToDiff(new DateTimeImmutable()),
Email\ByPassEmail::sendAllTo('USERNAME@MAILER.COM')
),
];
$command = new NotifierCommand($jiraHttpClient, $channels);
$result = $command->execute(NotifierInput::fromArray([
'COMPANY_NAME' => '~',
'JIRA_PROJECT_NAME' => '~',
'JIRA_API_LABEL' => 'auth-basic_API-LABEL',
'JIRA_API_PASSWORD' => 'auth-basic_API-PASSWORD',
'DAYS_FOR_STATUS' => [
"To Do" => 6,
"In Progress" => 4,
"Verified" => 1,
],
'JIRA_USERS_TO_IGNORE' => ['any.jira.user.key', 'another.jira.user.key'],
]));
$output = new NotifierOutput(new EchoOutput());
$output->write($result);