| 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 Response |
||
| 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 Response |
||
| 53 | */ |
||
| 54 | 6 | protected function postRaw($path, $body, array $headers = []) |
|
| 62 | |||
| 63 | /** |
||
| 64 | * Create a JSON encoded version of an array of parameters. |
||
| 65 | * |
||
| 66 | * @param array $parameters |
||
| 67 | * |
||
| 68 | * @return null|string |
||
| 69 | */ |
||
| 70 | 6 | protected function createJsonBody(array $parameters) |
|
| 78 | } |
||
| 79 |