1: | <?php |
2: | |
3: | |
4: | |
5: | namespace Worldline\Acquiring\Sdk\V1\Ping; |
6: | |
7: | use Worldline\Acquiring\Sdk\ApiResource; |
8: | use Worldline\Acquiring\Sdk\CallContext; |
9: | use Worldline\Acquiring\Sdk\Communication\ErrorResponseException; |
10: | use Worldline\Acquiring\Sdk\Communication\InvalidResponseException; |
11: | use Worldline\Acquiring\Sdk\Communication\ResponseClassMap; |
12: | use Worldline\Acquiring\Sdk\V1\ApiException; |
13: | use Worldline\Acquiring\Sdk\V1\AuthorizationException; |
14: | use Worldline\Acquiring\Sdk\V1\ExceptionFactory; |
15: | use Worldline\Acquiring\Sdk\V1\PlatformException; |
16: | use Worldline\Acquiring\Sdk\V1\ReferenceException; |
17: | use Worldline\Acquiring\Sdk\V1\ValidationException; |
18: | |
19: | |
20: | |
21: | |
22: | class PingClient extends ApiResource |
23: | { |
24: | |
25: | private $responseExceptionFactory = null; |
26: | |
27: | |
28: | |
29: | |
30: | |
31: | |
32: | |
33: | |
34: | |
35: | |
36: | |
37: | |
38: | |
39: | |
40: | |
41: | public function ping(CallContext $callContext = null) |
42: | { |
43: | $responseClassMap = new ResponseClassMap(); |
44: | $responseClassMap->defaultErrorResponseClassName = '\Worldline\Acquiring\Sdk\V1\Domain\ApiPaymentErrorResponse'; |
45: | try { |
46: | return $this->getCommunicator()->get( |
47: | $responseClassMap, |
48: | $this->instantiateUri('/services/v1/ping'), |
49: | null, |
50: | $callContext |
51: | ); |
52: | } catch (ErrorResponseException $e) { |
53: | throw $this->getResponseExceptionFactory()->createException( |
54: | $e->getHttpStatusCode(), |
55: | $e->getErrorResponse(), |
56: | $callContext |
57: | ); |
58: | } |
59: | } |
60: | |
61: | |
62: | private function getResponseExceptionFactory() |
63: | { |
64: | if (is_null($this->responseExceptionFactory)) { |
65: | $this->responseExceptionFactory = new ExceptionFactory(); |
66: | } |
67: | return $this->responseExceptionFactory; |
68: | } |
69: | } |
70: | |