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 | * @var string |
||
36 | */ |
||
37 | private $body; |
||
38 | |||
39 | /** |
||
40 | * @param string $secret |
||
41 | * @param RequestInterface|null $request |
||
42 | */ |
||
43 | 8 | public function __construct($secret, RequestInterface $request = null) |
|
48 | |||
49 | /** |
||
50 | * Check if the request is a valid webhook request |
||
51 | * |
||
52 | * @return bool |
||
53 | */ |
||
54 | 3 | public function isValid() |
|
67 | |||
68 | /** |
||
69 | * @return CallbackEvent[] |
||
70 | */ |
||
71 | 1 | public function getAllCallbackEvents() |
|
81 | |||
82 | /** |
||
83 | * @return Entry[] |
||
84 | */ |
||
85 | 1 | public function getEntries() |
|
89 | |||
90 | /** |
||
91 | * @return RequestInterface |
||
92 | */ |
||
93 | 1 | public function getRequest() |
|
97 | |||
98 | /** |
||
99 | * @return array |
||
100 | */ |
||
101 | 4 | public function getDecodedBody() |
|
111 | |||
112 | /** |
||
113 | * @return Entry[] |
||
114 | */ |
||
115 | 2 | private function getHydratedEntries() |
|
132 | |||
133 | /** |
||
134 | * @return string |
||
135 | */ |
||
136 | 6 | private function getBody() |
|
149 | |||
150 | /** |
||
151 | * @return bool |
||
152 | */ |
||
153 | 3 | private function isValidHeader() |
|
165 | } |
||
166 |