Skip to content

Commit 14eea2a

Browse files
committed
[Notifier] Add options to Microsoft Teams notifier
1 parent ddb48bb commit 14eea2a

26 files changed

+1204
-1
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
*/
17+
abstract class AbstractMicrosoftTeamsAction implements MicrosoftTeamsActionInterface
18+
{
19+
protected $options = [];
20+
21+
public function toArray(): array
22+
{
23+
return $this->options;
24+
}
25+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
*/
17+
abstract class AbstractMicrosoftTeamsActionElement implements MicrosoftTeamsActionElementInterface
18+
{
19+
protected $options = [];
20+
21+
public function toArray(): array
22+
{
23+
return $this->options;
24+
}
25+
}
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+
*/
17+
abstract class AbstractMicrosoftTeamsActionInput implements MicrosoftTeamsActionInterface
18+
{
19+
protected $options = [];
20+
21+
/**
22+
* @return $this
23+
*/
24+
public function id(string $id): self
25+
{
26+
$this->options['id'] = $id;
27+
28+
return $this;
29+
}
30+
31+
/**
32+
* @return $this
33+
*/
34+
public function isRequired(bool $required): self
35+
{
36+
$this->options['isRequired'] = $required;
37+
38+
return $this;
39+
}
40+
41+
/**
42+
* @return $this
43+
*/
44+
public function title(string $title): self
45+
{
46+
$this->options['title'] = $title;
47+
48+
return $this;
49+
}
50+
51+
/**
52+
* @return $this
53+
*/
54+
public function value(string $value): self
55+
{
56+
$this->options['value'] = $value;
57+
58+
return $this;
59+
}
60+
61+
public function toArray(): array
62+
{
63+
return $this->options;
64+
}
65+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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\LogicException;
15+
16+
/**
17+
* @author Edouard Lescot <edouard.lescot@gmail.com>
18+
*
19+
* @see https://docs.microsoft.com/en-us/outlook/actionable-messages/message-card-reference#actioncard-action
20+
*/
21+
class MicrosoftTeamsActionCardAction extends AbstractMicrosoftTeamsAction
22+
{
23+
/**
24+
* @return $this
25+
*/
26+
public function name(string $name): self
27+
{
28+
$this->options['name'] = $name;
29+
30+
return $this;
31+
}
32+
33+
/**
34+
* @return $this
35+
*/
36+
public function input(MicrosoftTeamsActionInputInterface $inputAction): self
37+
{
38+
$this->options['inputs'][] = $inputAction->toArray();
39+
40+
return $this;
41+
}
42+
43+
/**
44+
* @return $this
45+
*/
46+
public function action(MicrosoftTeamsActionInterface $action): self
47+
{
48+
if (!\in_array(\get_class($action), [MicrosoftTeamsHttpPostAction::class, MicrosoftTeamsOpenUriAction::class])) {
49+
throw new LogicException(sprintf('"%s" must be an instance of "%s" or "%s".', \get_class($action), MicrosoftTeamsHttpPostAction::class, MicrosoftTeamsOpenUriAction::class));
50+
}
51+
52+
$this->options['actions'][] = $action->toArray();
53+
54+
return $this;
55+
}
56+
57+
public function toArray(): array
58+
{
59+
$this->options['@type'] = 'ActionCard';
60+
61+
return parent::toArray();
62+
}
63+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
*/
17+
interface MicrosoftTeamsActionElementInterface
18+
{
19+
public function toArray(): array;
20+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
*/
17+
interface MicrosoftTeamsActionInputInterface
18+
{
19+
public function toArray(): array;
20+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
*/
17+
interface MicrosoftTeamsActionInterface
18+
{
19+
public function toArray(): array;
20+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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+
*
17+
* @see https://docs.microsoft.com/en-us/outlook/actionable-messages/message-card-reference#dateinput
18+
*/
19+
class MicrosoftTeamsDateInputAction extends AbstractMicrosoftTeamsActionInput
20+
{
21+
/**
22+
* @return $this
23+
*/
24+
public function includeTime(bool $includeTime): self
25+
{
26+
$this->options['includeTime'] = $includeTime;
27+
28+
return $this;
29+
}
30+
31+
public function toArray(): array
32+
{
33+
$this->options['@type'] = 'DateInput';
34+
35+
return parent::toArray();
36+
}
37+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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+
*
17+
* @see https://docs.microsoft.com/en-us/outlook/actionable-messages/message-card-reference#header
18+
*/
19+
class MicrosoftTeamsHeaderActionElement extends AbstractMicrosoftTeamsActionElement
20+
{
21+
/**
22+
* @return $this
23+
*/
24+
public function name(string $name): self
25+
{
26+
$this->options['name'] = $name;
27+
28+
return $this;
29+
}
30+
31+
/**
32+
* @return $this
33+
*/
34+
public function value(string $value): self
35+
{
36+
$this->options['value'] = $value;
37+
38+
return $this;
39+
}
40+
}

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