1 | <?php |
||
27 | abstract class AbstractApiRequest implements ClientRequestInterface, ContextAwareInterface |
||
28 | { |
||
29 | use ContextTrait; |
||
30 | |||
31 | /** |
||
32 | * @var JsonEndpoint |
||
33 | */ |
||
34 | protected $endpoint; |
||
35 | |||
36 | /** |
||
37 | * @var array |
||
38 | */ |
||
39 | protected $params = []; |
||
40 | |||
41 | protected $identifier; |
||
42 | |||
43 | protected $resultClass = '\Commercetools\Core\Model\Common\JsonObject'; |
||
44 | |||
45 | /** |
||
46 | * @param JsonEndpoint $endpoint |
||
47 | * @param Context $context |
||
48 | */ |
||
49 | 913 | public function __construct(JsonEndpoint $endpoint, Context $context = null) |
|
54 | |||
55 | /** |
||
56 | * @return string |
||
57 | * @internal |
||
58 | */ |
||
59 | public function getResultClass() |
||
63 | |||
64 | /** |
||
65 | * @return string |
||
66 | */ |
||
67 | 352 | public function getIdentifier() |
|
75 | |||
76 | /** |
||
77 | * @param string $identifier |
||
78 | * @return $this |
||
79 | */ |
||
80 | 1 | public function setIdentifier($identifier) |
|
86 | |||
87 | /** |
||
88 | * @param JsonEndpoint $endpoint |
||
89 | * @return $this |
||
90 | * @internal |
||
91 | */ |
||
92 | 913 | protected function setEndpoint(JsonEndpoint $endpoint) |
|
98 | |||
99 | /** |
||
100 | * @return JsonEndpoint |
||
101 | * @internal |
||
102 | */ |
||
103 | 580 | public function getEndpoint() |
|
107 | |||
108 | /** |
||
109 | * @param $key |
||
110 | * @param $value |
||
111 | * @param bool $replace |
||
112 | * @return $this |
||
113 | */ |
||
114 | 42 | public function addParam($key, $value = null, $replace = true) |
|
124 | |||
125 | /** |
||
126 | * @param ParameterInterface $param |
||
127 | * @return $this |
||
128 | */ |
||
129 | 553 | public function addParamObject(ParameterInterface $param) |
|
135 | |||
136 | 579 | protected function convertToString($params) |
|
149 | /** |
||
150 | * @return string |
||
151 | * @internal |
||
152 | */ |
||
153 | 554 | protected function getParamString() |
|
159 | |||
160 | /** |
||
161 | * @return string |
||
162 | * @internal |
||
163 | */ |
||
164 | 479 | protected function getPath() |
|
168 | |||
169 | /** |
||
170 | * @param ResponseInterface $response |
||
171 | * @return ApiResponseInterface |
||
172 | * @internal |
||
173 | */ |
||
174 | abstract public function buildResponse(ResponseInterface $response); |
||
175 | |||
176 | /** |
||
177 | * @return RequestInterface |
||
178 | * @internal |
||
179 | */ |
||
180 | abstract public function httpRequest(); |
||
181 | |||
182 | |||
183 | /** |
||
184 | * @param array $result |
||
185 | * @param Context $context |
||
186 | * @return JsonDeserializeInterface|null |
||
187 | * @internal |
||
188 | */ |
||
189 | 251 | public function mapResult(array $result, Context $context = null) |
|
193 | |||
194 | /** |
||
195 | * @param ApiResponseInterface $response |
||
196 | * @return JsonDeserializeInterface|null |
||
197 | */ |
||
198 | 416 | public function mapResponse(ApiResponseInterface $response) |
|
202 | |||
203 | 418 | public function mapFromResponse(ApiResponseInterface $response, MapperInterface $mapper = null) |
|
215 | |||
216 | 615 | public function map(array $data, Context $context = null, MapperInterface $mapper = null) |
|
227 | |||
228 | /** |
||
229 | * @param Client $client |
||
230 | * @return ApiResponseInterface |
||
231 | */ |
||
232 | 423 | public function executeWithClient(Client $client) |
|
236 | } |
||
237 |