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