1 | <?php |
||
9 | class WebhookRequest |
||
10 | { |
||
11 | protected static $codes = [ |
||
12 | JSON_ERROR_CTRL_CHAR => 'Control character error, possibly incorrectly encoded.', |
||
13 | JSON_ERROR_DEPTH => 'The maximum stack depth has been exceeded.', |
||
14 | JSON_ERROR_NONE => 'No error has occurred.', |
||
15 | JSON_ERROR_STATE_MISMATCH => 'Invalid or malformed JSON.', |
||
16 | JSON_ERROR_SYNTAX => 'Syntax error.', |
||
17 | JSON_ERROR_UTF8 => 'Malformed UTF-8 characters, possibly incorrectly encoded.', |
||
18 | ]; |
||
19 | |||
20 | /** |
||
21 | * @var string |
||
22 | */ |
||
23 | protected $body; |
||
24 | |||
25 | /** |
||
26 | * @var array |
||
27 | */ |
||
28 | protected $headers; |
||
29 | |||
30 | /** |
||
31 | * @var string |
||
32 | */ |
||
33 | protected $clientIp; |
||
34 | |||
35 | /** |
||
36 | * @throws XsollaWebhookException |
||
37 | * @return WebhookRequest |
||
38 | */ |
||
39 | public static function fromGlobals() |
||
49 | |||
50 | /** |
||
51 | * @param array $headers |
||
52 | * @param string $body |
||
53 | * @param string $clientIp |
||
54 | */ |
||
55 | public function __construct(array $headers, $body, $clientIp = null) |
||
61 | |||
62 | /** |
||
63 | * @return string |
||
64 | */ |
||
65 | public function getBody() |
||
69 | |||
70 | /** |
||
71 | * @throws XsollaWebhookException |
||
72 | * @return array |
||
73 | */ |
||
74 | public function toArray() |
||
88 | |||
89 | /** |
||
90 | * @return array |
||
91 | */ |
||
92 | public function getHeaders() |
||
96 | |||
97 | /** |
||
98 | * @return string |
||
99 | */ |
||
100 | public function getClientIp() |
||
104 | } |
||
105 |