1 | <?php |
||
10 | class WebhookRequestHandler |
||
11 | { |
||
12 | /** |
||
13 | * @var RequestInterface |
||
14 | */ |
||
15 | private $request; |
||
16 | |||
17 | /** |
||
18 | * App secret used to verify the request sha1 |
||
19 | * |
||
20 | * @var string |
||
21 | */ |
||
22 | private $secret; |
||
23 | |||
24 | /** |
||
25 | * @var array |
||
26 | */ |
||
27 | private $decodedBody; |
||
28 | |||
29 | /** |
||
30 | * @var Entry[] |
||
31 | */ |
||
32 | private $hydratedEntries; |
||
33 | |||
34 | /** |
||
35 | * @param string $secret |
||
36 | * @param RequestInterface|null $request |
||
37 | */ |
||
38 | 8 | public function __construct($secret, RequestInterface $request = null) |
|
43 | |||
44 | /** |
||
45 | * Check if the request is a valid webhook request |
||
46 | * |
||
47 | * @return bool |
||
48 | */ |
||
49 | 3 | public function isValid() |
|
62 | |||
63 | /** |
||
64 | * @return CallbackEvent[] |
||
65 | */ |
||
66 | 1 | public function getAllCallbackEvents() |
|
76 | |||
77 | /** |
||
78 | * @return Entry[] |
||
79 | */ |
||
80 | 1 | public function getEntries() |
|
84 | |||
85 | /** |
||
86 | * @return RequestInterface |
||
87 | */ |
||
88 | 1 | public function getRequest() |
|
92 | |||
93 | /** |
||
94 | * @return array |
||
95 | */ |
||
96 | 4 | public function getDecodedBody() |
|
107 | |||
108 | /** |
||
109 | * @return Entry[] |
||
110 | */ |
||
111 | 2 | private function getHydratedEntries() |
|
128 | |||
129 | /** |
||
130 | * @return bool |
||
131 | */ |
||
132 | 3 | private function isValidHeader() |
|
145 | } |
||
146 |