1 | <?php |
||
8 | abstract class ApiAbstract |
||
9 | { |
||
10 | /** |
||
11 | * HTTP client. |
||
12 | * |
||
13 | * @var Client |
||
14 | */ |
||
15 | protected $client; |
||
16 | |||
17 | /** |
||
18 | * Assign dependencies. |
||
19 | * |
||
20 | * @param Client $client |
||
21 | */ |
||
22 | 12 | public function __construct(Client $client) |
|
26 | |||
27 | /** |
||
28 | * Send a POST request with JSON encoded parameters. |
||
29 | * |
||
30 | * @param string $path |
||
31 | * @param array $parameters |
||
32 | * @param array $headers |
||
33 | * |
||
34 | * @return array |
||
35 | */ |
||
36 | 6 | protected function post($path, array $parameters = [], array $headers = []) |
|
44 | |||
45 | /** |
||
46 | * Send a POST request with raw data. |
||
47 | * |
||
48 | * @param string $path |
||
49 | * @param mixed $body |
||
50 | * @param array $headers |
||
51 | * |
||
52 | * @return array |
||
53 | */ |
||
54 | 6 | protected function postRaw($path, $body, array $headers = []) |
|
64 | |||
65 | /** |
||
66 | * Create a JSON encoded version of an array of parameters. |
||
67 | * |
||
68 | * @param array $parameters |
||
69 | * |
||
70 | * @return null|string |
||
71 | */ |
||
72 | 6 | protected function createJsonBody(array $parameters) |
|
80 | |||
81 | /** |
||
82 | * Extracts the relevant content from the response. |
||
83 | * |
||
84 | * @param Response $response |
||
85 | * |
||
86 | * @return array|mixed |
||
87 | */ |
||
88 | 6 | protected function getResponse(Response $response) |
|
102 | |||
103 | 4 | protected function getQueryLimitHeaders(Response $response, array $limits = []) |
|
117 | } |
||
118 |