Skip to content

Commit 767698e

Browse files
committed
[Notifier] Add options to Microsoft Teams notifier
1 parent cc29772 commit 767698e

37 files changed

+2000
-3
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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\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+
class ActionCardAction implements ActionInterface
23+
{
24+
protected $options = [];
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+
$this->options['@type'] = 'ActionCard';
50+
51+
return $this->options;
52+
}
53+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
public function toArray(): array;
22+
}
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 ActionElementInterface
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;
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: 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;
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+
class HeaderActionElement 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+
/**
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#httppost-action
19+
*/
20+
class HttpPostAction implements ActionCardCompatibleActionInterface
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 target(string $url): self
32+
{
33+
$this->options['target'] = $url;
34+
35+
return $this;
36+
}
37+
38+
public function header(HeaderActionElement $header): self
39+
{
40+
$this->options['headers'][] = $header->toArray();
41+
42+
return $this;
43+
}
44+
45+
public function body(string $body): self
46+
{
47+
$this->options['body'] = $body;
48+
49+
return $this;
50+
}
51+
52+
public function bodyContentType(string $contentType): self
53+
{
54+
$this->options['bodyContentType'] = $contentType;
55+
56+
return $this;
57+
}
58+
59+
public function toArray(): array
60+
{
61+
$this->options['@type'] = 'HttpPOST';
62+
63+
return $this->options;
64+
}
65+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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+
* @see https://docs.microsoft.com/en-us/outlook/actionable-messages/message-card-reference#invokeaddincommand-action
19+
*/
20+
class InvokeAddInCommandAction implements ActionInterface
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 addInId(string $addInId): self
32+
{
33+
$this->options['addInId'] = $addInId;
34+
35+
return $this;
36+
}
37+
38+
public function desktopCommandId(string $desktopCommandId): self
39+
{
40+
$this->options['desktopCommandId'] = $desktopCommandId;
41+
42+
return $this;
43+
}
44+
45+
public function initializationContext(array $context): self
46+
{
47+
$this->options['initializationContext'] = $context;
48+
49+
return $this;
50+
}
51+
52+
public function toArray(): array
53+
{
54+
$this->options['@type'] = 'InvokeAddInCommand';
55+
56+
return $this->options;
57+
}
58+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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\Exception\InvalidArgumentException;
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#openuri-action
21+
*/
22+
class OpenUriAction implements ActionCardCompatibleActionInterface
23+
{
24+
private const OPERATING_SYSTEMS = [
25+
'android',
26+
'default',
27+
'iOS',
28+
'windows',
29+
];
30+
31+
protected $options = [];
32+
33+
public function name(string $name): self
34+
{
35+
$this->options['name'] = $name;
36+
37+
return $this;
38+
}
39+
40+
public function target(string $uri, string $os = 'default'): self
41+
{
42+
if (!\in_array($os, self::OPERATING_SYSTEMS)) {
43+
throw new InvalidArgumentException(sprintf('Supported operating systems for "%s" method are: "%s".', __METHOD__, implode('", "', self::OPERATING_SYSTEMS)));
44+
}
45+
46+
$this->options['targets'][] = ['os' => $os, 'uri' => $uri];
47+
48+
return $this;
49+
}
50+
51+
public function toArray(): array
52+
{
53+
$this->options['@type'] = 'OpenUri';
54+
55+
return $this->options;
56+
}
57+
}

src/Symfony/Component/Notifier/Bridge/MicrosoftTeams/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ CHANGELOG
55
---
66

77
* Add the bridge
8+
* Add options support

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy