1 | <?php |
||
28 | abstract class Api |
||
29 | { |
||
30 | /** |
||
31 | * @var bool |
||
32 | */ |
||
33 | protected $isSensitive = false; |
||
34 | |||
35 | /** |
||
36 | * @var string |
||
37 | */ |
||
38 | protected $countryCode = 'th'; |
||
39 | |||
40 | /** |
||
41 | * @var HttpClientInterface |
||
42 | */ |
||
43 | protected $httpClient; |
||
44 | |||
45 | /** |
||
46 | * @var array |
||
47 | */ |
||
48 | protected $options; |
||
49 | |||
50 | /** |
||
51 | * @var HydrationInterface |
||
52 | */ |
||
53 | private $hydration; |
||
54 | |||
55 | 62 | /** |
|
56 | * @param HttpClientInterface $httpClient |
||
57 | 62 | * @param array $options |
|
58 | * @param HydrationInterface $hydration |
||
59 | 62 | */ |
|
60 | 62 | public function __construct(HttpClientInterface $httpClient, array $options, HydrationInterface $hydration = null) |
|
72 | 62 | ||
73 | /** |
||
74 | 62 | * @param OptionsResolver $resolver |
|
75 | 62 | */ |
|
76 | 62 | protected function configureOptions(OptionsResolver $resolver) |
|
87 | |||
88 | /** |
||
89 | * @return string |
||
90 | */ |
||
91 | protected function getAuthorizationKey() |
||
95 | |||
96 | /** |
||
97 | * @return string |
||
98 | */ |
||
99 | protected function getApiServer() |
||
103 | |||
104 | /** |
||
105 | * @param string $method |
||
106 | * @param string $path |
||
107 | 51 | * @param array $data |
|
108 | * @param array $headers |
||
109 | 51 | * |
|
110 | * @return mixed|Model |
||
111 | 51 | * |
|
112 | 19 | * @throws InvalidResponseException |
|
113 | 19 | */ |
|
114 | protected function doRequest($method, $path, array $data = [], array $headers = []) |
||
128 | |||
129 | 51 | /** |
|
130 | * @param ResponseInterface $response |
||
131 | 51 | * |
|
132 | * @return mixed|Model |
||
133 | * |
||
134 | 51 | * @throws InvalidResponseException |
|
135 | */ |
||
136 | protected function hydrateResponse(ResponseInterface $response) |
||
159 | 39 | ||
160 | /** |
||
161 | 39 | * @param mixed $id |
|
162 | 11 | * @param string $message |
|
163 | * |
||
164 | 28 | * @throws InvalidRequestArgumentException |
|
165 | */ |
||
166 | protected static function assertNotEmpty($id, $message = 'Id can not be empty.') |
||
172 | } |
||
173 |