1 | <?php namespace Ntholenaar\MultiSafepayClient; |
||
16 | class Client implements ClientInterface |
||
17 | { |
||
18 | /** |
||
19 | * Optional ISO 639-1 language code. |
||
20 | * |
||
21 | * The localization parameter determines the language which is used to |
||
22 | * display gateway information and other messages in the responses. |
||
23 | * The default language is English. |
||
24 | * |
||
25 | * @var string |
||
26 | */ |
||
27 | protected $locale; |
||
28 | |||
29 | /** |
||
30 | * @var bool |
||
31 | */ |
||
32 | protected $testMode = false; |
||
33 | |||
34 | /** |
||
35 | * @var HttpClient |
||
36 | */ |
||
37 | protected $httpClient; |
||
38 | |||
39 | /** |
||
40 | * @var PluginClient |
||
41 | */ |
||
42 | protected $pluginClient; |
||
43 | |||
44 | /** |
||
45 | * @var UriFactory |
||
46 | */ |
||
47 | protected $uriFactory; |
||
48 | |||
49 | /** |
||
50 | * @var array |
||
51 | */ |
||
52 | protected $plugins = array(); |
||
53 | |||
54 | /** |
||
55 | * @param HttpClient $httpClient |
||
56 | * @param UriFactory|null $uriFactory |
||
57 | */ |
||
58 | public function __construct(HttpClient $httpClient = null, UriFactory $uriFactory = null) |
||
72 | |||
73 | /** |
||
74 | * Get the API endpoint. |
||
75 | * |
||
76 | * @return \Psr\Http\Message\UriInterface |
||
77 | */ |
||
78 | public function getApiEndpoint() |
||
86 | |||
87 | /** |
||
88 | * Get the API path. |
||
89 | * |
||
90 | * @return \Psr\Http\Message\UriInterface |
||
91 | */ |
||
92 | public function getApiPath() |
||
96 | |||
97 | /** |
||
98 | * Get the UriFactory. |
||
99 | * |
||
100 | * @return UriFactory |
||
101 | */ |
||
102 | protected function getUriFactory() |
||
106 | |||
107 | /** |
||
108 | * Set the UriFactory. |
||
109 | * |
||
110 | * @param UriFactory $uriFactory |
||
111 | * @return $this |
||
112 | */ |
||
113 | protected function setUriFactory(UriFactory $uriFactory) |
||
119 | |||
120 | /** |
||
121 | * Get the HttpClient. |
||
122 | * |
||
123 | * @return HttpClient |
||
124 | */ |
||
125 | protected function getHttpClient() |
||
129 | |||
130 | /** |
||
131 | * Set the HttpClient. |
||
132 | * |
||
133 | * @param HttpClient $httpClient |
||
134 | * @return $this |
||
135 | */ |
||
136 | protected function setHttpClient(HttpClient $httpClient) |
||
142 | |||
143 | /** |
||
144 | * Get the locale. |
||
145 | * |
||
146 | * @return string |
||
147 | */ |
||
148 | public function getLocale() |
||
152 | |||
153 | /** |
||
154 | * Set the locale. |
||
155 | * |
||
156 | * @param $locale |
||
157 | * @return $this |
||
158 | */ |
||
159 | public function setLocale($locale) |
||
165 | |||
166 | /** |
||
167 | * Enable or disable the test environment. |
||
168 | * |
||
169 | * @param $testMode |
||
170 | * @return $this |
||
171 | */ |
||
172 | public function setTestMode($testMode) |
||
178 | |||
179 | /** |
||
180 | * Is the test environment active. |
||
181 | * |
||
182 | * @return bool |
||
183 | */ |
||
184 | public function isTestModeEnabled() |
||
188 | |||
189 | /** |
||
190 | * Set the API key. |
||
191 | * |
||
192 | * @param $apiKey |
||
193 | * @return $this |
||
194 | */ |
||
195 | public function setApiKey($apiKey) |
||
205 | |||
206 | /** |
||
207 | * Add an Http plugin. |
||
208 | * |
||
209 | * @param Plugin $plugin |
||
210 | * @return $this |
||
211 | */ |
||
212 | public function addHttpPlugin(Plugin $plugin) |
||
220 | |||
221 | /** |
||
222 | * Invalidate the PluginClient instance. |
||
223 | * |
||
224 | * @return $this |
||
225 | */ |
||
226 | protected function invalidatePluginClient() |
||
232 | |||
233 | /** |
||
234 | * Get the PluginClient. |
||
235 | * |
||
236 | * @return PluginClient |
||
237 | */ |
||
238 | protected function getPluginClient() |
||
259 | |||
260 | /** |
||
261 | * Execute the Http Request. |
||
262 | * |
||
263 | * @param RequestInterface $request |
||
264 | * @return array|object |
||
265 | */ |
||
266 | public function executeRequest(RequestInterface $request) |
||
272 | |||
273 | /** |
||
274 | * Parse the response. |
||
275 | * |
||
276 | * @param ResponseInterface $response |
||
277 | * @return array|object |
||
278 | */ |
||
279 | protected function parseResponse(ResponseInterface $response) |
||
289 | |||
290 | /** |
||
291 | * Validate the response. |
||
292 | * |
||
293 | * @param $response |
||
294 | * @return bool |
||
295 | * @throws InvalidRequestException |
||
296 | */ |
||
297 | protected function validateResponse($response) |
||
305 | |||
306 | /** |
||
307 | * Create an GatewayRequest. |
||
308 | * |
||
309 | * @return GatewayRequest |
||
310 | */ |
||
311 | public function createGatewayRequest() |
||
315 | |||
316 | /** |
||
317 | * Create an IssuerRequest. |
||
318 | * |
||
319 | * @return IssuerRequest |
||
320 | */ |
||
321 | public function createIssuerRequest() |
||
325 | |||
326 | /** |
||
327 | * Create an new request. |
||
328 | * |
||
329 | * @param $resource |
||
330 | * @return \Ntholenaar\MultiSafepayClient\Request\RequestInterface |
||
331 | */ |
||
332 | public function createRequest($resource) |
||
344 | } |