1 | <?php namespace Ntholenaar\MultiSafepayClient; |
||
17 | class Client implements ClientInterface |
||
18 | { |
||
19 | /** |
||
20 | * Optional ISO 639-1 language code. |
||
21 | * |
||
22 | * The localization parameter determines the language which is used to |
||
23 | * display gateway information and other messages in the responses. |
||
24 | * The default language is English. |
||
25 | * |
||
26 | * @var string |
||
27 | */ |
||
28 | protected $locale; |
||
29 | |||
30 | /** |
||
31 | * @var bool |
||
32 | */ |
||
33 | protected $testMode = false; |
||
34 | |||
35 | /** |
||
36 | * @var HttpClient |
||
37 | */ |
||
38 | protected $httpClient; |
||
39 | |||
40 | /** |
||
41 | * @var PluginClient |
||
42 | */ |
||
43 | protected $pluginClient; |
||
44 | |||
45 | /** |
||
46 | * @var UriFactory |
||
47 | */ |
||
48 | protected $uriFactory; |
||
49 | |||
50 | /** |
||
51 | * @var array |
||
52 | */ |
||
53 | protected $plugins = array(); |
||
54 | |||
55 | /** |
||
56 | * @param HttpClient $httpClient |
||
57 | * @param UriFactory|null $uriFactory |
||
58 | */ |
||
59 | public function __construct(HttpClient $httpClient = null, UriFactory $uriFactory = null) |
||
73 | |||
74 | /** |
||
75 | * {@inheritdoc} |
||
76 | */ |
||
77 | public function getApiEndpoint() |
||
85 | |||
86 | /** |
||
87 | * {@inheritdoc} |
||
88 | */ |
||
89 | public function getApiPath() |
||
93 | |||
94 | /** |
||
95 | * Get the UriFactory. |
||
96 | * |
||
97 | * @return UriFactory |
||
98 | */ |
||
99 | protected function getUriFactory() |
||
103 | |||
104 | /** |
||
105 | * Set the UriFactory. |
||
106 | * |
||
107 | * @param UriFactory $uriFactory |
||
108 | * @return $this |
||
109 | */ |
||
110 | protected function setUriFactory(UriFactory $uriFactory) |
||
116 | |||
117 | /** |
||
118 | * Get the HttpClient. |
||
119 | * |
||
120 | * @return HttpClient |
||
121 | */ |
||
122 | protected function getHttpClient() |
||
126 | |||
127 | /** |
||
128 | * Set the HttpClient. |
||
129 | * |
||
130 | * @param HttpClient $httpClient |
||
131 | * @return $this |
||
132 | */ |
||
133 | protected function setHttpClient(HttpClient $httpClient) |
||
139 | |||
140 | /** |
||
141 | * {@inheritdoc} |
||
142 | */ |
||
143 | public function getLocale() |
||
147 | |||
148 | /** |
||
149 | * {@inheritdoc} |
||
150 | */ |
||
151 | public function setLocale($locale) |
||
157 | |||
158 | /** |
||
159 | * {@inheritdoc} |
||
160 | */ |
||
161 | public function setTestMode($testMode) |
||
167 | |||
168 | /** |
||
169 | * {@inheritdoc} |
||
170 | */ |
||
171 | public function isTestModeEnabled() |
||
175 | |||
176 | /** |
||
177 | * {@inheritdoc} |
||
178 | */ |
||
179 | public function setApiKey($apiKey) |
||
189 | |||
190 | /** |
||
191 | * {@inheritdoc} |
||
192 | */ |
||
193 | public function addHttpPlugin(Plugin $plugin) |
||
201 | |||
202 | /** |
||
203 | * Invalidate the PluginClient instance. |
||
204 | * |
||
205 | * @return $this |
||
206 | */ |
||
207 | protected function invalidatePluginClient() |
||
213 | |||
214 | /** |
||
215 | * Get the PluginClient. |
||
216 | * |
||
217 | * @return PluginClient |
||
218 | */ |
||
219 | protected function getPluginClient() |
||
240 | |||
241 | /** |
||
242 | * {@inheritdoc} |
||
243 | */ |
||
244 | public function executeRequest(RequestInterface $request) |
||
250 | |||
251 | /** |
||
252 | * Parse the response. |
||
253 | * |
||
254 | * @param ResponseInterface $response |
||
255 | * @return array|object |
||
256 | */ |
||
257 | protected function parseResponse(ResponseInterface $response) |
||
267 | |||
268 | /** |
||
269 | * Validate the response. |
||
270 | * |
||
271 | * @param $response |
||
272 | * @return bool |
||
273 | * @throws InvalidRequestException |
||
274 | */ |
||
275 | protected function validateResponse($response) |
||
283 | |||
284 | /** |
||
285 | * {@inheritdoc} |
||
286 | */ |
||
287 | public function createGatewayRequest() |
||
291 | |||
292 | /** |
||
293 | * {@inheritdoc} |
||
294 | */ |
||
295 | public function createIssuerRequest() |
||
299 | |||
300 | /** |
||
301 | * {@inheritdoc} |
||
302 | */ |
||
303 | public function createOrderRequest() |
||
307 | |||
308 | /** |
||
309 | * {@inheritdoc} |
||
310 | */ |
||
311 | public function createRequest($resource) |
||
326 | } |
||
327 |