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 | * @throws \Exception |
||
113 | */ |
||
114 | 1 | private function respondToSlack($data) |
|
118 | |||
119 | /** |
||
120 | * @param $data |
||
121 | */ |
||
122 | 7 | private function respondAsJSON($data) |
|
131 | |||
132 | /** |
||
133 | * Specify the response type |
||
134 | * If response in config is set to empty, it will be considered based on listener. |
||
135 | * |
||
136 | * @return mixed|string |
||
137 | * @throws \Exception |
||
138 | */ |
||
139 | 9 | private function getResponseType() |
|
149 | |||
150 | /** |
||
151 | * @return string |
||
152 | * @throws \Exception |
||
153 | */ |
||
154 | 2 | private function getResponseByListenerType(): string |
|
166 | |||
167 | /** |
||
168 | * Send confirmation. |
||
169 | * @throws BotonomousException |
||
170 | */ |
||
171 | 1 | public function sendConfirmation() |
|
194 | } |
||
195 |