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) |
|
53 | |||
54 | /** |
||
55 | * Check if the request is a valid webhook request |
||
56 | * |
||
57 | * @return bool |
||
58 | */ |
||
59 | 3 | public function isValid() |
|
72 | |||
73 | /** |
||
74 | * @return CallbackEvent[] |
||
75 | */ |
||
76 | 1 | public function getAllCallbackEvents() |
|
86 | |||
87 | /** |
||
88 | * @return Entry[] |
||
89 | */ |
||
90 | 1 | public function getEntries() |
|
94 | |||
95 | /** |
||
96 | * @return RequestInterface |
||
97 | */ |
||
98 | 1 | public function getRequest() |
|
102 | |||
103 | /** |
||
104 | * @return array |
||
105 | */ |
||
106 | 4 | public function getDecodedBody() |
|
116 | |||
117 | /** |
||
118 | * @return Entry[] |
||
119 | */ |
||
120 | 2 | private function getHydratedEntries() |
|
137 | |||
138 | /** |
||
139 | * @return bool |
||
140 | */ |
||
141 | 3 | private function isValidHeader() |
|
153 | } |
||
154 |