1 | <?php |
||
10 | class Sender extends AbstractSender |
||
11 | { |
||
12 | const SLACK_RESPONSE_TYPE = 'slack'; |
||
13 | const SLASH_COMMAND_RESPONSE_TYPE = 'slashCommand'; |
||
14 | const JSON_RESPONSE_TYPE = 'json'; |
||
15 | |||
16 | private $slackbot; |
||
17 | |||
18 | /** |
||
19 | * Sender constructor. |
||
20 | * |
||
21 | * @param AbstractBot $slackbot |
||
22 | */ |
||
23 | 13 | public function __construct(AbstractBot $slackbot) |
|
27 | |||
28 | /** |
||
29 | * @return AbstractBot |
||
30 | */ |
||
31 | 9 | public function getSlackbot(): AbstractBot |
|
35 | |||
36 | /** |
||
37 | * @param AbstractBot $slackbot |
||
38 | */ |
||
39 | 13 | public function setSlackbot(AbstractBot $slackbot) |
|
43 | |||
44 | /** |
||
45 | * Final endpoint for the response. |
||
46 | * |
||
47 | * @param $channel |
||
48 | * @param $text |
||
49 | * @param $attachments |
||
50 | * |
||
51 | * @throws \Exception |
||
52 | * |
||
53 | * @return bool |
||
54 | */ |
||
55 | 9 | public function send($text, $channel = null, $attachments = null) |
|
89 | |||
90 | /** |
||
91 | * @param $response |
||
92 | */ |
||
93 | 1 | private function respondToSlashCommand($response) |
|
109 | |||
110 | /** |
||
111 | * @param $data |
||
112 | * |
||
113 | * @throws \Exception |
||
114 | */ |
||
115 | 1 | private function respondToSlack($data) |
|
119 | |||
120 | /** |
||
121 | * @param $data |
||
122 | */ |
||
123 | 7 | private function respondAsJSON($data) |
|
132 | |||
133 | /** |
||
134 | * Specify the response type |
||
135 | * If response in config is set to empty, it will be considered based on listener. |
||
136 | * |
||
137 | * @throws \Exception |
||
138 | * |
||
139 | * @return mixed|string |
||
140 | */ |
||
141 | 9 | private function getResponseType() |
|
151 | |||
152 | /** |
||
153 | * @throws \Exception |
||
154 | * |
||
155 | * @return string |
||
156 | */ |
||
157 | 2 | private function getResponseByListenerType(): string |
|
169 | |||
170 | /** |
||
171 | * Send confirmation. |
||
172 | * |
||
173 | * @throws BotonomousException |
||
174 | */ |
||
175 | 1 | public function sendConfirmation() |
|
198 | } |
||
199 |