1: | <?php |
2: | |
3: | |
4: | |
5: | |
6: | namespace Worldline\Connect\Sdk\V1\Merchant\Services; |
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\BankDetailsRequest; |
16: | use Worldline\Connect\Sdk\V1\Domain\BankDetailsResponse; |
17: | use Worldline\Connect\Sdk\V1\Domain\ConvertAmount; |
18: | use Worldline\Connect\Sdk\V1\Domain\GetIINDetailsRequest; |
19: | use Worldline\Connect\Sdk\V1\Domain\GetIINDetailsResponse; |
20: | use Worldline\Connect\Sdk\V1\Domain\GetPrivacyPolicyResponse; |
21: | use Worldline\Connect\Sdk\V1\Domain\TestConnection; |
22: | use Worldline\Connect\Sdk\V1\ExceptionFactory; |
23: | use Worldline\Connect\Sdk\V1\IdempotenceException; |
24: | use Worldline\Connect\Sdk\V1\PlatformException; |
25: | use Worldline\Connect\Sdk\V1\ReferenceException; |
26: | use Worldline\Connect\Sdk\V1\ValidationException; |
27: | |
28: | |
29: | |
30: | |
31: | class ServicesClient extends ApiResource |
32: | { |
33: | |
34: | private $responseExceptionFactory = null; |
35: | |
36: | |
37: | |
38: | |
39: | |
40: | |
41: | |
42: | |
43: | |
44: | |
45: | |
46: | |
47: | |
48: | |
49: | |
50: | |
51: | |
52: | public function convertAmount(ConvertAmountParams $query, CallContext $callContext = null) |
53: | { |
54: | $responseClassMap = new ResponseClassMap(); |
55: | $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ConvertAmount'; |
56: | $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse'; |
57: | try { |
58: | return $this->getCommunicator()->get( |
59: | $responseClassMap, |
60: | $this->instantiateUri('/v1/{merchantId}/services/convert/amount'), |
61: | $this->getClientMetaInfo(), |
62: | $query, |
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: | |
76: | |
77: | |
78: | |
79: | |
80: | |
81: | |
82: | |
83: | |
84: | |
85: | |
86: | |
87: | |
88: | |
89: | |
90: | public function bankaccount(BankDetailsRequest $body, CallContext $callContext = null) |
91: | { |
92: | $responseClassMap = new ResponseClassMap(); |
93: | $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\BankDetailsResponse'; |
94: | $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse'; |
95: | try { |
96: | return $this->getCommunicator()->post( |
97: | $responseClassMap, |
98: | $this->instantiateUri('/v1/{merchantId}/services/convert/bankaccount'), |
99: | $this->getClientMetaInfo(), |
100: | $body, |
101: | null, |
102: | $callContext |
103: | ); |
104: | } catch (ErrorResponseException $e) { |
105: | throw $this->getResponseExceptionFactory()->createException( |
106: | $e->getHttpStatusCode(), |
107: | $e->getErrorResponse(), |
108: | $callContext |
109: | ); |
110: | } |
111: | } |
112: | |
113: | |
114: | |
115: | |
116: | |
117: | |
118: | |
119: | |
120: | |
121: | |
122: | |
123: | |
124: | |
125: | |
126: | |
127: | |
128: | |
129: | public function getIINdetails(GetIINDetailsRequest $body, CallContext $callContext = null) |
130: | { |
131: | $responseClassMap = new ResponseClassMap(); |
132: | $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\GetIINDetailsResponse'; |
133: | $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse'; |
134: | try { |
135: | return $this->getCommunicator()->post( |
136: | $responseClassMap, |
137: | $this->instantiateUri('/v1/{merchantId}/services/getIINdetails'), |
138: | $this->getClientMetaInfo(), |
139: | $body, |
140: | null, |
141: | $callContext |
142: | ); |
143: | } catch (ErrorResponseException $e) { |
144: | throw $this->getResponseExceptionFactory()->createException( |
145: | $e->getHttpStatusCode(), |
146: | $e->getErrorResponse(), |
147: | $callContext |
148: | ); |
149: | } |
150: | } |
151: | |
152: | |
153: | |
154: | |
155: | |
156: | |
157: | |
158: | |
159: | |
160: | |
161: | |
162: | |
163: | |
164: | |
165: | |
166: | |
167: | |
168: | public function privacypolicy(PrivacypolicyParams $query, CallContext $callContext = null) |
169: | { |
170: | $responseClassMap = new ResponseClassMap(); |
171: | $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\GetPrivacyPolicyResponse'; |
172: | $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse'; |
173: | try { |
174: | return $this->getCommunicator()->get( |
175: | $responseClassMap, |
176: | $this->instantiateUri('/v1/{merchantId}/services/privacypolicy'), |
177: | $this->getClientMetaInfo(), |
178: | $query, |
179: | $callContext |
180: | ); |
181: | } catch (ErrorResponseException $e) { |
182: | throw $this->getResponseExceptionFactory()->createException( |
183: | $e->getHttpStatusCode(), |
184: | $e->getErrorResponse(), |
185: | $callContext |
186: | ); |
187: | } |
188: | } |
189: | |
190: | |
191: | |
192: | |
193: | |
194: | |
195: | |
196: | |
197: | |
198: | |
199: | |
200: | |
201: | |
202: | |
203: | |
204: | |
205: | public function testconnection(CallContext $callContext = null) |
206: | { |
207: | $responseClassMap = new ResponseClassMap(); |
208: | $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\TestConnection'; |
209: | $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse'; |
210: | try { |
211: | return $this->getCommunicator()->get( |
212: | $responseClassMap, |
213: | $this->instantiateUri('/v1/{merchantId}/services/testconnection'), |
214: | $this->getClientMetaInfo(), |
215: | null, |
216: | $callContext |
217: | ); |
218: | } catch (ErrorResponseException $e) { |
219: | throw $this->getResponseExceptionFactory()->createException( |
220: | $e->getHttpStatusCode(), |
221: | $e->getErrorResponse(), |
222: | $callContext |
223: | ); |
224: | } |
225: | } |
226: | |
227: | |
228: | private function getResponseExceptionFactory() |
229: | { |
230: | if (is_null($this->responseExceptionFactory)) { |
231: | $this->responseExceptionFactory = new ExceptionFactory(); |
232: | } |
233: | return $this->responseExceptionFactory; |
234: | } |
235: | } |
236: | |