Skip to content
Jose Maria Valera Reales edited this page Dec 5, 2019 · 17 revisions

Welcome to the ScrumMaster wiki!

Example

Here you can see an implementation example using the NotifierCommand with multiple channels (Slack and Email).

<?php 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('USER@MAIL.COM', 'pA$SWoRd')),
        Email\MessageGenerator::withTimeToDiff(new DateTimeImmutable()),
        Email\ByPassEmail::sendAllTo('USER@MAILER.COM')
    ),
];

$notifier = new NotifierCommand($jiraHttpClient, $channels);

$result = $notifier->execute(NotifierInput::new(
    $companyName = '~',
    $jiraProjectName = '~',
    $daysForStatus = [
        "To Do" => 6,
        "In Progress" => 4,
        "Verified" => 1,
    ],
    $jiraUsersToIgnore = ['any.jira.user.key', 'another.jira.user.key']
));

$output = new NotifierOutput(new EchoOutput());
$output->write($result);
Clone this wiki locally