1: <?php
2: /*
3: * This class was auto-generated from the API references found at
4: * https://apireference.connect.worldline-solutions.com/
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: * Files client.
23: */
24: class FilesClient extends ApiResource
25: {
26: /** @var ExceptionFactory|null */
27: private $responseExceptionFactory = null;
28:
29: /**
30: * Resource /{merchantId}/files/{fileId} - Retrieve File
31: *
32: * @param string $fileId
33: * @param callable $bodyHandler Callable accepting a response body chunk and the response headers
34: * @param CallContext $callContext
35: *
36: * @throws IdempotenceException
37: * @throws ValidationException
38: * @throws AuthorizationException
39: * @throws ReferenceException
40: * @throws PlatformException
41: * @throws ApiException
42: * @throws InvalidResponseException
43: * @link https://apireference.connect.worldline-solutions.com/fileserviceapi/v1/en_US/php/files/getFile.html Retrieve File
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: /** @return ExceptionFactory */
69: private function getResponseExceptionFactory()
70: {
71: if (is_null($this->responseExceptionFactory)) {
72: $this->responseExceptionFactory = new ExceptionFactory();
73: }
74: return $this->responseExceptionFactory;
75: }
76: }
77: