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