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