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\Products;
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\CreatePaymentProductSessionRequest;
16: use Worldline\Connect\Sdk\V1\Domain\CreatePaymentProductSessionResponse;
17: use Worldline\Connect\Sdk\V1\Domain\DeviceFingerprintRequest;
18: use Worldline\Connect\Sdk\V1\Domain\DeviceFingerprintResponse;
19: use Worldline\Connect\Sdk\V1\Domain\Directory;
20: use Worldline\Connect\Sdk\V1\Domain\GetCustomerDetailsRequest;
21: use Worldline\Connect\Sdk\V1\Domain\GetCustomerDetailsResponse;
22: use Worldline\Connect\Sdk\V1\Domain\PaymentProductNetworksResponse;
23: use Worldline\Connect\Sdk\V1\Domain\PaymentProductResponse;
24: use Worldline\Connect\Sdk\V1\Domain\PaymentProducts;
25: use Worldline\Connect\Sdk\V1\ExceptionFactory;
26: use Worldline\Connect\Sdk\V1\IdempotenceException;
27: use Worldline\Connect\Sdk\V1\PlatformException;
28: use Worldline\Connect\Sdk\V1\ReferenceException;
29: use Worldline\Connect\Sdk\V1\ValidationException;
30:
31: /**
32: * Products client.
33: */
34: class ProductsClient extends ApiResource
35: {
36: /** @var ExceptionFactory|null */
37: private $responseExceptionFactory = null;
38:
39: /**
40: * Resource /{merchantId}/products - Get payment products
41: *
42: * @param FindProductsParams $query
43: * @param CallContext $callContext
44: * @return PaymentProducts
45: *
46: * @throws IdempotenceException
47: * @throws ValidationException
48: * @throws AuthorizationException
49: * @throws ReferenceException
50: * @throws PlatformException
51: * @throws ApiException
52: * @throws InvalidResponseException
53: * @link https://apireference.connect.worldline-solutions.com/s2sapi/v1/en_US/php/products/find.html Get payment products
54: */
55: public function find(FindProductsParams $query, CallContext $callContext = null)
56: {
57: $responseClassMap = new ResponseClassMap();
58: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\PaymentProducts';
59: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse';
60: try {
61: return $this->getCommunicator()->get(
62: $responseClassMap,
63: $this->instantiateUri('/v1/{merchantId}/products'),
64: $this->getClientMetaInfo(),
65: $query,
66: $callContext
67: );
68: } catch (ErrorResponseException $e) {
69: throw $this->getResponseExceptionFactory()->createException(
70: $e->getHttpStatusCode(),
71: $e->getErrorResponse(),
72: $callContext
73: );
74: }
75: }
76:
77: /**
78: * Resource /{merchantId}/products/{paymentProductId} - Get payment product
79: *
80: * @param int $paymentProductId
81: * @param GetProductParams $query
82: * @param CallContext $callContext
83: * @return PaymentProductResponse
84: *
85: * @throws IdempotenceException
86: * @throws ValidationException
87: * @throws AuthorizationException
88: * @throws ReferenceException
89: * @throws PlatformException
90: * @throws ApiException
91: * @throws InvalidResponseException
92: * @link https://apireference.connect.worldline-solutions.com/s2sapi/v1/en_US/php/products/get.html Get payment product
93: */
94: public function get($paymentProductId, GetProductParams $query, CallContext $callContext = null)
95: {
96: $this->context['paymentProductId'] = $paymentProductId;
97: $responseClassMap = new ResponseClassMap();
98: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\PaymentProductResponse';
99: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse';
100: try {
101: return $this->getCommunicator()->get(
102: $responseClassMap,
103: $this->instantiateUri('/v1/{merchantId}/products/{paymentProductId}'),
104: $this->getClientMetaInfo(),
105: $query,
106: $callContext
107: );
108: } catch (ErrorResponseException $e) {
109: throw $this->getResponseExceptionFactory()->createException(
110: $e->getHttpStatusCode(),
111: $e->getErrorResponse(),
112: $callContext
113: );
114: }
115: }
116:
117: /**
118: * Resource /{merchantId}/products/{paymentProductId}/directory - Get payment product directory
119: *
120: * @param int $paymentProductId
121: * @param DirectoryParams $query
122: * @param CallContext $callContext
123: * @return Directory
124: *
125: * @throws IdempotenceException
126: * @throws ValidationException
127: * @throws AuthorizationException
128: * @throws ReferenceException
129: * @throws PlatformException
130: * @throws ApiException
131: * @throws InvalidResponseException
132: * @link https://apireference.connect.worldline-solutions.com/s2sapi/v1/en_US/php/products/directory.html Get payment product directory
133: */
134: public function directory($paymentProductId, DirectoryParams $query, CallContext $callContext = null)
135: {
136: $this->context['paymentProductId'] = $paymentProductId;
137: $responseClassMap = new ResponseClassMap();
138: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\Directory';
139: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse';
140: try {
141: return $this->getCommunicator()->get(
142: $responseClassMap,
143: $this->instantiateUri('/v1/{merchantId}/products/{paymentProductId}/directory'),
144: $this->getClientMetaInfo(),
145: $query,
146: $callContext
147: );
148: } catch (ErrorResponseException $e) {
149: throw $this->getResponseExceptionFactory()->createException(
150: $e->getHttpStatusCode(),
151: $e->getErrorResponse(),
152: $callContext
153: );
154: }
155: }
156:
157: /**
158: * Resource /{merchantId}/products/{paymentProductId}/customerDetails - Get customer details
159: *
160: * @param int $paymentProductId
161: * @param GetCustomerDetailsRequest $body
162: * @param CallContext $callContext
163: * @return GetCustomerDetailsResponse
164: *
165: * @throws IdempotenceException
166: * @throws ValidationException
167: * @throws AuthorizationException
168: * @throws ReferenceException
169: * @throws PlatformException
170: * @throws ApiException
171: * @throws InvalidResponseException
172: * @link https://apireference.connect.worldline-solutions.com/s2sapi/v1/en_US/php/products/customerDetails.html Get customer details
173: */
174: public function customerDetails($paymentProductId, GetCustomerDetailsRequest $body, CallContext $callContext = null)
175: {
176: $this->context['paymentProductId'] = $paymentProductId;
177: $responseClassMap = new ResponseClassMap();
178: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\GetCustomerDetailsResponse';
179: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse';
180: try {
181: return $this->getCommunicator()->post(
182: $responseClassMap,
183: $this->instantiateUri('/v1/{merchantId}/products/{paymentProductId}/customerDetails'),
184: $this->getClientMetaInfo(),
185: $body,
186: null,
187: $callContext
188: );
189: } catch (ErrorResponseException $e) {
190: throw $this->getResponseExceptionFactory()->createException(
191: $e->getHttpStatusCode(),
192: $e->getErrorResponse(),
193: $callContext
194: );
195: }
196: }
197:
198: /**
199: * Resource /{merchantId}/products/{paymentProductId}/deviceFingerprint - Get device fingerprint
200: *
201: * @param int $paymentProductId
202: * @param DeviceFingerprintRequest $body
203: * @param CallContext $callContext
204: * @return DeviceFingerprintResponse
205: *
206: * @throws IdempotenceException
207: * @throws ValidationException
208: * @throws AuthorizationException
209: * @throws ReferenceException
210: * @throws PlatformException
211: * @throws ApiException
212: * @throws InvalidResponseException
213: * @link https://apireference.connect.worldline-solutions.com/s2sapi/v1/en_US/php/products/deviceFingerprint.html Get device fingerprint
214: */
215: public function deviceFingerprint($paymentProductId, DeviceFingerprintRequest $body, CallContext $callContext = null)
216: {
217: $this->context['paymentProductId'] = $paymentProductId;
218: $responseClassMap = new ResponseClassMap();
219: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\DeviceFingerprintResponse';
220: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse';
221: try {
222: return $this->getCommunicator()->post(
223: $responseClassMap,
224: $this->instantiateUri('/v1/{merchantId}/products/{paymentProductId}/deviceFingerprint'),
225: $this->getClientMetaInfo(),
226: $body,
227: null,
228: $callContext
229: );
230: } catch (ErrorResponseException $e) {
231: throw $this->getResponseExceptionFactory()->createException(
232: $e->getHttpStatusCode(),
233: $e->getErrorResponse(),
234: $callContext
235: );
236: }
237: }
238:
239: /**
240: * Resource /{merchantId}/products/{paymentProductId}/networks - Get payment product networks
241: *
242: * @param int $paymentProductId
243: * @param NetworksParams $query
244: * @param CallContext $callContext
245: * @return PaymentProductNetworksResponse
246: *
247: * @throws IdempotenceException
248: * @throws ValidationException
249: * @throws AuthorizationException
250: * @throws ReferenceException
251: * @throws PlatformException
252: * @throws ApiException
253: * @throws InvalidResponseException
254: * @link https://apireference.connect.worldline-solutions.com/s2sapi/v1/en_US/php/products/networks.html Get payment product networks
255: */
256: public function networks($paymentProductId, NetworksParams $query, CallContext $callContext = null)
257: {
258: $this->context['paymentProductId'] = $paymentProductId;
259: $responseClassMap = new ResponseClassMap();
260: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\PaymentProductNetworksResponse';
261: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse';
262: try {
263: return $this->getCommunicator()->get(
264: $responseClassMap,
265: $this->instantiateUri('/v1/{merchantId}/products/{paymentProductId}/networks'),
266: $this->getClientMetaInfo(),
267: $query,
268: $callContext
269: );
270: } catch (ErrorResponseException $e) {
271: throw $this->getResponseExceptionFactory()->createException(
272: $e->getHttpStatusCode(),
273: $e->getErrorResponse(),
274: $callContext
275: );
276: }
277: }
278:
279: /**
280: * Resource /{merchantId}/products/{paymentProductId}/sessions - Create session for payment product
281: *
282: * @param int $paymentProductId
283: * @param CreatePaymentProductSessionRequest $body
284: * @param CallContext $callContext
285: * @return CreatePaymentProductSessionResponse
286: *
287: * @throws IdempotenceException
288: * @throws ValidationException
289: * @throws AuthorizationException
290: * @throws ReferenceException
291: * @throws PlatformException
292: * @throws ApiException
293: * @throws InvalidResponseException
294: * @link https://apireference.connect.worldline-solutions.com/s2sapi/v1/en_US/php/products/sessions.html Create session for payment product
295: */
296: public function sessions($paymentProductId, CreatePaymentProductSessionRequest $body, CallContext $callContext = null)
297: {
298: $this->context['paymentProductId'] = $paymentProductId;
299: $responseClassMap = new ResponseClassMap();
300: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\CreatePaymentProductSessionResponse';
301: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse';
302: try {
303: return $this->getCommunicator()->post(
304: $responseClassMap,
305: $this->instantiateUri('/v1/{merchantId}/products/{paymentProductId}/sessions'),
306: $this->getClientMetaInfo(),
307: $body,
308: null,
309: $callContext
310: );
311: } catch (ErrorResponseException $e) {
312: throw $this->getResponseExceptionFactory()->createException(
313: $e->getHttpStatusCode(),
314: $e->getErrorResponse(),
315: $callContext
316: );
317: }
318: }
319:
320: /** @return ExceptionFactory */
321: private function getResponseExceptionFactory()
322: {
323: if (is_null($this->responseExceptionFactory)) {
324: $this->responseExceptionFactory = new ExceptionFactory();
325: }
326: return $this->responseExceptionFactory;
327: }
328: }
329: