1: <?php
2: /*
3: * This file was automatically generated.
4: */
5: namespace Worldline\Acquiring\Sdk\V1\Disputedocuments;
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\Domain\UploadDocumentResponse;
15: use Worldline\Acquiring\Sdk\V1\ExceptionFactory;
16: use Worldline\Acquiring\Sdk\V1\PlatformException;
17: use Worldline\Acquiring\Sdk\V1\ReferenceException;
18: use Worldline\Acquiring\Sdk\V1\ValidationException;
19:
20: /**
21: * DisputeDocuments client.
22: *
23: * @package Worldline\Acquiring\Sdk\V1\Disputedocuments
24: */
25: class DisputeDocumentsClient extends ApiResource
26: {
27: /**
28: * @var ExceptionFactory|null
29: */
30: private ?ExceptionFactory $responseExceptionFactory = null;
31:
32: /**
33: * Resource /dispute-management/v1/documents - Upload Dispute Document
34: *
35: * @param UploadDisputeDocumentRequest $body
36: * @param CallContext|null $callContext
37: *
38: * @return UploadDocumentResponse
39: * @throws ValidationException
40: * @throws AuthorizationException
41: * @throws ReferenceException
42: * @throws PlatformException
43: * @throws ApiException
44: * @throws InvalidResponseException
45: * @link https://docs.acquiring.worldline-solutions.com/api-reference#tag/Dispute-Documents/operation/uploadDisputeDocument Upload Dispute Document
46: */
47: public function uploadDisputeDocument(UploadDisputeDocumentRequest $body, ?CallContext $callContext = null): UploadDocumentResponse
48: {
49: $responseClassMap = new ResponseClassMap();
50: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Acquiring\Sdk\V1\Domain\UploadDocumentResponse';
51: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Acquiring\Sdk\V1\Domain\ApiPaymentErrorResponse';
52: try {
53: return $this->getCommunicator()->post(
54: $responseClassMap,
55: $this->instantiateUri('/dispute-management/v1/documents'),
56: $body,
57: null,
58: $callContext
59: );
60: } catch (ErrorResponseException $e) {
61: throw $this->getResponseExceptionFactory()->createException(
62: $e->getHttpStatusCode(),
63: $e->getErrorResponse(),
64: $callContext
65: );
66: }
67: }
68:
69: /**
70: * Resource /dispute-management/v1/disputes/{disputeId}/documents/{documentId} - Retrieve Dispute Document
71: *
72: * @param string $disputeId
73: * @param string $documentId
74: * @param callable $bodyHandler Callable accepting a response body chunk and the response headers
75: * @param CallContext|null $callContext
76: *
77: * @return void
78: * @throws ValidationException
79: * @throws AuthorizationException
80: * @throws ReferenceException
81: * @throws PlatformException
82: * @throws ApiException
83: * @throws InvalidResponseException
84: * @link https://docs.acquiring.worldline-solutions.com/api-reference#tag/Dispute-Documents/operation/getDisputeDocument Retrieve Dispute Document
85: */
86: public function getDisputeDocument(string $disputeId, string $documentId, callable $bodyHandler, ?CallContext $callContext = null): void
87: {
88: $this->context['disputeId'] = $disputeId;
89: $this->context['documentId'] = $documentId;
90: $responseClassMap = new ResponseClassMap();
91: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Acquiring\Sdk\V1\Domain\ApiPaymentErrorResponse';
92: try {
93: $this->getCommunicator()->getWithBinaryResponse(
94: $bodyHandler,
95: $responseClassMap,
96: $this->instantiateUri('/dispute-management/v1/disputes/{disputeId}/documents/{documentId}'),
97: null,
98: $callContext
99: );
100: } catch (ErrorResponseException $e) {
101: throw $this->getResponseExceptionFactory()->createException(
102: $e->getHttpStatusCode(),
103: $e->getErrorResponse(),
104: $callContext
105: );
106: }
107: }
108:
109: /**
110: * @return ExceptionFactory
111: */
112: private function getResponseExceptionFactory(): ExceptionFactory
113: {
114: if (is_null($this->responseExceptionFactory)) {
115: $this->responseExceptionFactory = new ExceptionFactory();
116: }
117: return $this->responseExceptionFactory;
118: }
119: }
120: