8000 [Notifier] Add options to Microsoft Teams notifier · symfony/symfony@95129e9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 95129e9

Browse files
committed
[Notifier] Add options to Microsoft Teams notifier
1 parent eb70687 commit 95129e9

37 files changed

+2104
-4
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
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 Symfony\Component\Notifier\Bridge\MicrosoftTeams\Action;
13+
14+
use Symfony\Component\Notifier\Bridge\MicrosoftTeams\Action\Input\InputInterface;
15+
16+
/**
17+
* @author Edouard Lescot <edouard.lescot@gmail.com>
18+
* @author Oskar Stark <oskarstark@googlemail.com>
19+
*
20+
* @see https://docs.microsoft.com/en-us/outlook/actionable-messages/message-card-reference#actioncard-action
21+
*/
22+
final class ActionCard implements ActionInterface
23+
{
24+
protected $options = ['@type' => 'ActionCard'];
25+
26+
public function name(string $name): self
27+
{
28+
$this->options['name'] = $name;
29+
30+
return $this;
31+
}
32+
33+
public function input(InputInterface $inputAction): self
34+
{
35+
$this->options['inputs'][] = $inputAction->toArray();
36+
37+
return $this;
38+
}
39+
40+
public function action(ActionCardCompatibleActionInterface $action): self
41+
{
42+
$this->options['actions'][] = $action->toArray();
43+
44+
return $this;
45+
}
46+
47+
public function toArray(): array
48+
{
49+
return $this->options;
50+
}
51+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
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 Symfony\Component\Notifier\Bridge\MicrosoftTeams\Action;
13+
14+
/**
15+
* An Action which can be used inside an ActionCard.
16+
*
17+
* @author Oskar Stark <oskarstark@googlemail.com>
18+
*/
19+
interface ActionCardCompatibleActionInterface extends ActionInterface
20+
{
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
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 Symfony\Component\Notifier\Bridge\MicrosoftTeams\Action;
13+
14+
/**
15+
* @author Edouard Lescot <edouard.lescot@gmail.com>
16+
* @author Oskar Stark <oskarstark@googlemail.com>
17+
*/
18+
interface ActionInterface
19+
{
20+
public function toArray(): array;
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
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 Symfony\Component\Notifier\Bridge\MicrosoftTeams\Action\Element;
13+
14+
/**
15+
* @author Edouard Lescot <edouard.lescot@gmail.com>
16+
* @author Oskar Stark <oskarstark@googlemail.com>
17+
*/
18+
interface ActionElementInterface
19+
{
20+
public function toArray(): array;
21+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
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 Symfony\Component\Notifier\Bridge\MicrosoftTeams\Action\Element;
13+
14+
/**
15+
* @author Edouard Lescot <edouard.lescot@gmail.com>
16+
* @author Oskar Stark <oskarstark@googlemail.com>
17+
*
18+
* @see https://docs.microsoft.com/en-us/outlook/actionable-messages/message-card-reference#header
19+
*/
20+
final class Header implements ActionElementInterface
21+
{
22+
protected $options = [];
23+
24+
public function name(string $name): self
25+
{
26+
$this->options['name'] = $name;
27+
28+
return $this;
29+
}
30+
31+
public function value(string $value): self
32+
{
33+
$this->options['value'] = $value;
34+
35+
return $this;
36+
}
37+
38+
public function toArray(): array
39+
{
40+
return $this->options;
41+
}
42+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
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 Symfony\Component\Notifier\Bridge\MicrosoftTeams\Action;
13+
14+
use Symfony\Component\Notifier\Bridge\MicrosoftTeams\Action\Element\Header;
15+
16+
/**
17+
* @author Edouard Lescot <edouard.lescot@gmail.com>
18+
* @author Oskar Stark <oskarstark@googlemail.com>
19+
*
20+
* @see https://docs.microsoft.com/en-us/outlook/actionable-messages/message-card-reference#httppost-action
21+
*/
22+
final class HttpPostAction implements ActionCardCompatibleActionInterface
23+
{
24+
protected $options = ['@type' => 'HttpPOST'];
25+
26+
public function name(string $name): self
27+
{
28+
$this->options['name'] = $name;
29+
30+
return $this;
31+
}
32+
33+
public function target(string $url): self
34+
{
35+
$this->options['target'] = $url;
36+
37+
return $this;
38+
}
39+
40+
public function header(Header $header): self
41+
{
42+
$this->options['headers'][] = $header->toArray();
43+
44+
return $this;
45+
}
46+
47+
public function body(string $body): self
48+
{
49+
$this->options['body'] = $body;
50+
51+
return $this;
52+
}
53+
54+
public function bodyContentType(string $contentType): self
55+
{
56+
$this->options['bodyContentType'] = $contentType;
57+
58+
return $this;
59+
}
60+
61+
public function toArray(): array
62+
{
63+
return $this->options;
64+
}
65+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
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 Symfony\Component\Notifier\Bridge\MicrosoftTeams\Action\Input;
13+
14+
/**
15+
* @author Edouard Lescot <edouard.lescot@gmail.com>
16+
* @author Oskar Stark <oskarstark@googlemail.com>
17+
*/
18+
abstract class AbstractInput implements InputInterface
19+
{
20+
protected $options = [];
21+
22+
public function id(string $id): self
23+
{
24+
$this->options['id'] = $id;
25+
26+
return $this;
27+
}
28+
29+
public function isRequired(bool $required): self
30+
{
31+
$this->options['isRequired'] = $required;
32+
33+
return $this;
34+
}
35+
36+
public function title(string $title): self
37+
{
38+
$this->options['title'] = $title;
39+
40+
return $this;
41+
}
42+
43+
public function value(string $value): self
44+
{
45+
$this->options['value'] = $value;
46+
47+
return $this;
48+
}
49+
50+
public function toArray(): array
51+
{
52+
return $this->options;
53+
}
54+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
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 Symfony\Component\Notifier\Bridge\MicrosoftTeams\Action\Input;
13+
14+
/**
15+
* @author Edouard Lescot <edouard.lescot@gmail.com>
16+
* @author Oskar Stark <oskarstark@googlemail.com>
17+
*
18+
* @see https://docs.microsoft.com/en-us/outlook/actionable-messages/message-card-reference#dateinput
19+
*/
20+
final clas CEA4 s DateInput extends AbstractInput
21+
{
22+
public function includeTime(bool $includeTime): self
23+
{
24+
$this->options['includeTime'] = $includeTime;
25+
26+
return $this;
27+
}
28+
29+
public function toArray(): array
30+
{
31+
$this->options['@type'] = 'DateInput';
32+
33+
return parent::toArray();
34+
}
35+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
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 Symfony\Component\Notifier\Bridge\MicrosoftTeams\Action\Input;
13+
14+
/**
15+
* @author Edouard Lescot <edouard.lescot@gmail.com>
16+
* @author Oskar Stark <oskarstark@googlemail.com>
17+
*/
18+
interface InputInterface
19+
{
20+
public function toArray(): array;
21+
}

0 commit comments

Comments
 (0)
0