|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* Copyright (C) 2018 |
|
5
|
|
|
* Nathan Boiron <[email protected]> |
|
6
|
|
|
* Romain Canon <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* This file is part of the TYPO3 NotiZ project. |
|
9
|
|
|
* It is free software; you can redistribute it and/or modify it |
|
10
|
|
|
* under the terms of the GNU General Public License, either |
|
11
|
|
|
* version 3 of the License, or any later version. |
|
12
|
|
|
* |
|
13
|
|
|
* For the full copyright and license information, see: |
|
14
|
|
|
* http://www.gnu.org/licenses/gpl-3.0.html |
|
15
|
|
|
*/ |
|
16
|
|
|
|
|
17
|
|
|
namespace CuyZ\Notiz\Domain\Notification\Slack\Application\EntitySlack\Data; |
|
18
|
|
|
|
|
19
|
|
|
use CuyZ\Notiz\Domain\Notification\Slack\Application\EntitySlack\EntitySlackNotification; |
|
20
|
|
|
use CuyZ\Notiz\Domain\Notification\Slack\Application\EntitySlack\Settings\Channels\Channel as ChannelDefinition; |
|
21
|
|
|
|
|
22
|
|
|
class SlackChannel |
|
23
|
|
|
{ |
|
24
|
|
|
/** |
|
25
|
|
|
* @var string |
|
26
|
|
|
*/ |
|
27
|
|
|
private $webhookUrl; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @var string |
|
31
|
|
|
*/ |
|
32
|
|
|
private $target; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @param string $webhookUrl |
|
36
|
|
|
* @param string $target |
|
37
|
|
|
*/ |
|
38
|
|
|
private function __construct($webhookUrl, $target) |
|
39
|
|
|
{ |
|
40
|
|
|
$this->webhookUrl = $webhookUrl; |
|
41
|
|
|
$this->target = $target; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @param EntitySlackNotification $notification |
|
46
|
|
|
* @return static |
|
47
|
|
|
*/ |
|
48
|
|
|
public static function fromNotification(EntitySlackNotification $notification) |
|
49
|
|
|
{ |
|
50
|
|
|
return new static( |
|
51
|
|
|
$notification->getWebhookUrl(), |
|
52
|
|
|
$notification->getTarget() |
|
53
|
|
|
); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @param ChannelDefinition $channel |
|
58
|
|
|
* @return static |
|
59
|
|
|
*/ |
|
60
|
|
|
public static function fromDefinition(ChannelDefinition $channel) |
|
61
|
|
|
{ |
|
62
|
|
|
return new static($channel->getWebhookUrl(), $channel->getTarget()); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* @return string |
|
67
|
|
|
*/ |
|
68
|
|
|
public function getWebhookUrl() |
|
69
|
|
|
{ |
|
70
|
|
|
return $this->webhookUrl; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* @return string |
|
75
|
|
|
*/ |
|
76
|
|
|
public function getTarget() |
|
77
|
|
|
{ |
|
78
|
|
|
return $this->target; |
|
79
|
|
|
} |
|
80
|
|
|
} |
|
81
|
|
|
|