1: | <?php |
2: | |
3: | |
4: | |
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: | |
25: | |
26: | class DisputesClient extends ApiResource |
27: | { |
28: | |
29: | private $responseExceptionFactory = null; |
30: | |
31: | |
32: | |
33: | |
34: | |
35: | |
36: | |
37: | |
38: | |
39: | |
40: | |
41: | |
42: | |
43: | |
44: | |
45: | |
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: | |
72: | |
73: | |
74: | |
75: | |
76: | |
77: | |
78: | |
79: | |
80: | |
81: | |
82: | |
83: | |
84: | |
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: | |
112: | |
113: | |
114: | |
115: | |
116: | |
117: | |
118: | |
119: | |
120: | |
121: | |
122: | |
123: | |
124: | |
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: | |
152: | |
153: | |
154: | |
155: | |
156: | |
157: | |
158: | |
159: | |
160: | |
161: | |
162: | |
163: | |
164: | |
165: | |
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: | |
192: | private function getResponseExceptionFactory() |
193: | { |
194: | if (is_null($this->responseExceptionFactory)) { |
195: | $this->responseExceptionFactory = new ExceptionFactory(); |
196: | } |
197: | return $this->responseExceptionFactory; |
198: | } |
199: | } |
200: | |