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: * @package Worldline\Connect\Sdk\V1\Merchant\Files
25: */
26: class FilesClient extends ApiResource
27: {
28: /**
29: * @var ExceptionFactory|null
30: */
31: private ?ExceptionFactory $responseExceptionFactory = null;
32:
33: /**
34: * Resource /{merchantId}/files/{fileId} - Retrieve File
35: *
36: * @param string $fileId
37: * @param callable $bodyHandler Callable accepting a response body chunk and the response headers
38: * @param CallContext|null $callContext
39: *
40: * @return void
41: * @throws IdempotenceException
42: * @throws ValidationException
43: * @throws AuthorizationException
44: * @throws ReferenceException
45: * @throws PlatformException
46: * @throws ApiException
47: * @throws InvalidResponseException
48: * @link https://apireference.connect.worldline-solutions.com/fileserviceapi/v1/en_US/php/files/getFile.html Retrieve File
49: */
50: public function getFile(string $fileId, callable $bodyHandler, ?CallContext $callContext = null): void
51: {
52: $this->context['fileId'] = $fileId;
53: $responseClassMap = new ResponseClassMap();
54: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse';
55: try {
56: $this->getCommunicator()->getWithBinaryResponse(
57: $bodyHandler,
58: $responseClassMap,
59: $this->instantiateUri('/files/v1/{merchantId}/files/{fileId}'),
60: $this->getClientMetaInfo(),
61: null,
62: $callContext
63: );
64: } catch (ErrorResponseException $e) {
65: throw $this->getResponseExceptionFactory()->createException(
66: $e->getHttpStatusCode(),
67: $e->getErrorResponse(),
68: $callContext
69: );
70: }
71: }
72:
73: /**
74: * @return ExceptionFactory
75: */
76: private function getResponseExceptionFactory(): ExceptionFactory
77: {
78: if (is_null($this->responseExceptionFactory)) {
79: $this->responseExceptionFactory = new ExceptionFactory();
80: }
81: return $this->responseExceptionFactory;
82: }
83: }
84: