1 | <?php |
||
13 | class Webhook |
||
14 | { |
||
15 | /** |
||
16 | * @var EventDispatcherInterface |
||
17 | */ |
||
18 | protected $eventDispatcher; |
||
19 | |||
20 | /** |
||
21 | * @var string |
||
22 | */ |
||
23 | protected $eventName; |
||
24 | |||
25 | /** |
||
26 | * @var string |
||
27 | */ |
||
28 | protected $payload; |
||
29 | |||
30 | /** |
||
31 | * @var string |
||
32 | */ |
||
33 | protected $delivery; |
||
34 | |||
35 | /** |
||
36 | * @var array |
||
37 | */ |
||
38 | protected $eventMap; |
||
39 | |||
40 | /** |
||
41 | * Webhook constructor. |
||
42 | * @param EventDispatcherInterface $eventDispatcher |
||
43 | */ |
||
44 | public function __construct(EventDispatcherInterface $eventDispatcher = null) |
||
49 | |||
50 | /** |
||
51 | * @param string $event |
||
52 | * @return string |
||
53 | */ |
||
54 | public function getEventClassName($event) |
||
60 | |||
61 | /** |
||
62 | * @return array |
||
63 | */ |
||
64 | public function getDefaultEventNames() |
||
95 | |||
96 | /** |
||
97 | * @return array |
||
98 | */ |
||
99 | public function getEventMap() |
||
120 | |||
121 | /** |
||
122 | * @param Request $request |
||
123 | * @param string $secret |
||
124 | * @return bool |
||
125 | */ |
||
126 | public function isValidRequest(Request $request, $secret) |
||
136 | |||
137 | /** |
||
138 | * @param Request $request |
||
139 | * @param string $secret |
||
140 | * @param bool $dispatch |
||
141 | * @return EventBase |
||
142 | * |
||
143 | * @throws \InvalidArgumentException |
||
144 | */ |
||
145 | public function parseRequest(Request $request, $secret, $dispatch = true) |
||
163 | |||
164 | /** |
||
165 | * @param Request $request |
||
166 | * @param string $secret |
||
167 | * @return bool |
||
168 | * |
||
169 | * @throws \InvalidArgumentException |
||
170 | */ |
||
171 | protected function checkSecurity(Request $request, $secret) |
||
196 | |||
197 | /** |
||
198 | * @param string $secret |
||
199 | * @param string $signatureHeader |
||
200 | * @param string $payload |
||
201 | * @return bool |
||
202 | */ |
||
203 | protected function validateSignature($secret, $signatureHeader, $payload) |
||
210 | } |
||
211 |