1 | <?php |
||
22 | abstract class AbstractApi |
||
23 | { |
||
24 | /** @var \Fnayou\InstapushPHP\InstapushClient */ |
||
25 | private $instapushClient; |
||
26 | |||
27 | /** @var \Psr\Http\Message\RequestInterface */ |
||
28 | private $request; |
||
29 | |||
30 | /** @var \Psr\Http\Message\ResponseInterface */ |
||
31 | private $response; |
||
32 | |||
33 | /** |
||
34 | * @param \Fnayou\InstapushPHP\InstapushClient $instapushClient |
||
35 | */ |
||
36 | public function __construct(InstapushClient $instapushClient) |
||
40 | |||
41 | /** |
||
42 | * @return \Fnayou\InstapushPHP\InstapushClient |
||
43 | */ |
||
44 | public function getInstapushClient() |
||
48 | |||
49 | /** |
||
50 | * @return \Psr\Http\Message\RequestInterface |
||
51 | */ |
||
52 | public function getRequest() |
||
56 | |||
57 | /** |
||
58 | * @return \Psr\Http\Message\ResponseInterface |
||
59 | */ |
||
60 | public function getResponse() |
||
64 | |||
65 | /** |
||
66 | * @param \Fnayou\InstapushPHP\InstapushClient $instapushClient |
||
67 | * |
||
68 | * @return $this |
||
69 | */ |
||
70 | protected function setInstapushClient(InstapushClient $instapushClient) |
||
76 | |||
77 | /** |
||
78 | * @param \Psr\Http\Message\RequestInterface $request |
||
79 | * |
||
80 | * @return $this |
||
81 | */ |
||
82 | protected function setRequest(RequestInterface $request) |
||
88 | |||
89 | /** |
||
90 | * @param \Psr\Http\Message\ResponseInterface $response |
||
91 | * |
||
92 | * @return $this |
||
93 | */ |
||
94 | protected function setResponse(ResponseInterface $response) |
||
100 | |||
101 | /** |
||
102 | * @param string $path |
||
103 | * @param array $parameters |
||
104 | * @param array $headers |
||
105 | * |
||
106 | * @return $this |
||
107 | */ |
||
108 | protected function doGet(string $path, array $parameters = [], array $headers = []) |
||
130 | |||
131 | /** |
||
132 | * @param string $path |
||
133 | * @param array $parameters |
||
134 | * @param array $headers |
||
135 | * |
||
136 | * @return $this |
||
137 | */ |
||
138 | protected function doPost(string $path, array $parameters = [], array $headers = []) |
||
158 | |||
159 | /** |
||
160 | * @param string $class |
||
161 | * |
||
162 | * @return mixed |
||
163 | */ |
||
164 | protected function transformResponse(string $class = null) |
||
178 | |||
179 | /** |
||
180 | * @throws \Fnayou\InstapushPHP\Exception\ApiException |
||
181 | * |
||
182 | * @return \Fnayou\InstapushPHP\Model\ApiError |
||
183 | */ |
||
184 | protected function handleException() |
||
201 | |||
202 | /** |
||
203 | * @param ResponseInterface $response |
||
204 | * |
||
205 | * @throws \Fnayou\InstapushPHP\Exception\ApiException |
||
206 | */ |
||
207 | protected function handleNotJsonException(ResponseInterface $response) |
||
222 | } |
||
223 |