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\Disputes;
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\Domain\DisputeResponse;
16: use Worldline\Connect\Sdk\V1\Domain\UploadDisputeFileResponse;
17: use Worldline\Connect\Sdk\V1\ExceptionFactory;
18: use Worldline\Connect\Sdk\V1\IdempotenceException;
19: use Worldline\Connect\Sdk\V1\PlatformException;
20: use Worldline\Connect\Sdk\V1\ReferenceException;
21: use Worldline\Connect\Sdk\V1\ValidationException;
22:
23: /**
24: * Disputes client.
25: *
26: * @package Worldline\Connect\Sdk\V1\Merchant\Disputes
27: */
28: class DisputesClient extends ApiResource
29: {
30: /**
31: * @var ExceptionFactory|null
32: */
33: private ?ExceptionFactory $responseExceptionFactory = null;
34:
35: /**
36: * Resource /{merchantId}/disputes/{disputeId} - Get dispute
37: *
38: * @param string $disputeId
39: * @param CallContext|null $callContext
40: *
41: * @return DisputeResponse
42: * @throws IdempotenceException
43: * @throws ValidationException
44: * @throws AuthorizationException
45: * @throws ReferenceException
46: * @throws PlatformException
47: * @throws ApiException
48: * @throws InvalidResponseException
49: * @link https://apireference.connect.worldline-solutions.com/s2sapi/v1/en_US/php/disputes/get.html Get dispute
50: */
51: public function get(string $disputeId, ?CallContext $callContext = null): DisputeResponse
52: {
53: $this->context['disputeId'] = $disputeId;
54: $responseClassMap = new ResponseClassMap();
55: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\DisputeResponse';
56: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse';
57: try {
58: return $this->getCommunicator()->get(
59: $responseClassMap,
60: $this->instantiateUri('/v1/{merchantId}/disputes/{disputeId}'),
61: $this->getClientMetaInfo(),
62: null,
63: $callContext
64: );
65: } catch (ErrorResponseException $e) {
66: throw $this->getResponseExceptionFactory()->createException(
67: $e->getHttpStatusCode(),
68: $e->getErrorResponse(),
69: $callContext
70: );
71: }
72: }
73:
74: /**
75: * Resource /{merchantId}/disputes/{disputeId}/submit - Submit dispute
76: *
77: * @param string $disputeId
78: * @param CallContext|null $callContext
79: *
80: * @return DisputeResponse
81: * @throws IdempotenceException
82: * @throws ValidationException
83: * @throws AuthorizationException
84: * @throws ReferenceException
85: * @throws PlatformException
86: * @throws ApiException
87: * @throws InvalidResponseException
88: * @link https://apireference.connect.worldline-solutions.com/s2sapi/v1/en_US/php/disputes/submit.html Submit dispute
89: */
90: public function submit(string $disputeId, ?CallContext $callContext = null): DisputeResponse
91: {
92: $this->context['disputeId'] = $disputeId;
93: $responseClassMap = new ResponseClassMap();
94: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\DisputeResponse';
95: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse';
96: try {
97: return $this->getCommunicator()->post(
98: $responseClassMap,
99: $this->instantiateUri('/v1/{merchantId}/disputes/{disputeId}/submit'),
100: $this->getClientMetaInfo(),
101: null,
102: null,
103: $callContext
104: );
105: } catch (ErrorResponseException $e) {
106: throw $this->getResponseExceptionFactory()->createException(
107: $e->getHttpStatusCode(),
108: $e->getErrorResponse(),
109: $callContext
110: );
111: }
112: }
113:
114: /**
115: * Resource /{merchantId}/disputes/{disputeId}/cancel - Cancel dispute
116: *
117: * @param string $disputeId
118: * @param CallContext|null $callContext
119: *
120: * @return DisputeResponse
121: * @throws IdempotenceException
122: * @throws ValidationException
123: * @throws AuthorizationException
124: * @throws ReferenceException
125: * @throws PlatformException
126: * @throws ApiException
127: * @throws InvalidResponseException
128: * @link https://apireference.connect.worldline-solutions.com/s2sapi/v1/en_US/php/disputes/cancel.html Cancel dispute
129: */
130: public function cancel(string $disputeId, ?CallContext $callContext = null): DisputeResponse
131: {
132: $this->context['disputeId'] = $disputeId;
133: $responseClassMap = new ResponseClassMap();
134: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\DisputeResponse';
135: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse';
136: try {
137: return $this->getCommunicator()->post(
138: $responseClassMap,
139: $this->instantiateUri('/v1/{merchantId}/disputes/{disputeId}/cancel'),
140: $this->getClientMetaInfo(),
141: null,
142: null,
143: $callContext
144: );
145: } catch (ErrorResponseException $e) {
146: throw $this->getResponseExceptionFactory()->createException(
147: $e->getHttpStatusCode(),
148: $e->getErrorResponse(),
149: $callContext
150: );
151: }
152: }
153:
154: /**
155: * Resource /{merchantId}/disputes/{disputeId} - Upload File
156: *
157: * @param string $disputeId
158: * @param UploadFileRequest $body
159: * @param CallContext|null $callContext
160: *
161: * @return UploadDisputeFileResponse
162: * @throws IdempotenceException
163: * @throws ValidationException
164: * @throws AuthorizationException
165: * @throws ReferenceException
166: * @throws PlatformException
167: * @throws ApiException
168: * @throws InvalidResponseException
169: * @link https://apireference.connect.worldline-solutions.com/fileserviceapi/v1/en_US/php/disputes/uploadFile.html Upload File
170: */
171: public function uploadFile(string $disputeId, UploadFileRequest $body, ?CallContext $callContext = null): UploadDisputeFileResponse
172: {
173: $this->context['disputeId'] = $disputeId;
174: $responseClassMap = new ResponseClassMap();
175: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\UploadDisputeFileResponse';
176: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse';
177: try {
178: return $this->getCommunicator()->post(
179: $responseClassMap,
180: $this->instantiateUri('/files/v1/{merchantId}/disputes/{disputeId}'),
181: $this->getClientMetaInfo(),
182: $body,
183: null,
184: $callContext
185: );
186: } catch (ErrorResponseException $e) {
187: throw $this->getResponseExceptionFactory()->createException(
188: $e->getHttpStatusCode(),
189: $e->getErrorResponse(),
190: $callContext
191: );
192: }
193: }
194:
195: /**
196: * @return ExceptionFactory
197: */
198: private function getResponseExceptionFactory(): ExceptionFactory
199: {
200: if (is_null($this->responseExceptionFactory)) {
201: $this->responseExceptionFactory = new ExceptionFactory();
202: }
203: return $this->responseExceptionFactory;
204: }
205: }
206: