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\Productgroups;
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\DeviceFingerprintRequest;
16: use Worldline\Connect\Sdk\V1\Domain\DeviceFingerprintResponse;
17: use Worldline\Connect\Sdk\V1\Domain\PaymentProductGroupResponse;
18: use Worldline\Connect\Sdk\V1\Domain\PaymentProductGroups;
19: use Worldline\Connect\Sdk\V1\ExceptionFactory;
20: use Worldline\Connect\Sdk\V1\IdempotenceException;
21: use Worldline\Connect\Sdk\V1\PlatformException;
22: use Worldline\Connect\Sdk\V1\ReferenceException;
23: use Worldline\Connect\Sdk\V1\ValidationException;
24:
25: /**
26: * Product Groups client.
27: *
28: * @package Worldline\Connect\Sdk\V1\Merchant\Productgroups
29: */
30: class ProductgroupsClient extends ApiResource
31: {
32: /**
33: * @var ExceptionFactory|null
34: */
35: private ?ExceptionFactory $responseExceptionFactory = null;
36:
37: /**
38: * Resource /{merchantId}/productgroups - Get payment product groups
39: *
40: * @param FindProductgroupsParams $query
41: * @param CallContext|null $callContext
42: *
43: * @return PaymentProductGroups
44: * @throws IdempotenceException
45: * @throws ValidationException
46: * @throws AuthorizationException
47: * @throws ReferenceException
48: * @throws PlatformException
49: * @throws ApiException
50: * @throws InvalidResponseException
51: * @link https://apireference.connect.worldline-solutions.com/s2sapi/v1/en_US/php/productgroups/find.html Get payment product groups
52: */
53: public function find(FindProductgroupsParams $query, ?CallContext $callContext = null): PaymentProductGroups
54: {
55: $responseClassMap = new ResponseClassMap();
56: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\PaymentProductGroups';
57: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse';
58: try {
59: return $this->getCommunicator()->get(
60: $responseClassMap,
61: $this->instantiateUri('/v1/{merchantId}/productgroups'),
62: $this->getClientMetaInfo(),
63: $query,
64: $callContext
65: );
66: } catch (ErrorResponseException $e) {
67: throw $this->getResponseExceptionFactory()->createException(
68: $e->getHttpStatusCode(),
69: $e->getErrorResponse(),
70: $callContext
71: );
72: }
73: }
74:
75: /**
76: * Resource /{merchantId}/productgroups/{paymentProductGroupId} - Get payment product group
77: *
78: * @param string $paymentProductGroupId
79: * @param GetProductgroupParams $query
80: * @param CallContext|null $callContext
81: *
82: * @return PaymentProductGroupResponse
83: * @throws IdempotenceException
84: * @throws ValidationException
85: * @throws AuthorizationException
86: * @throws ReferenceException
87: * @throws PlatformException
88: * @throws ApiException
89: * @throws InvalidResponseException
90: * @link https://apireference.connect.worldline-solutions.com/s2sapi/v1/en_US/php/productgroups/get.html Get payment product group
91: */
92: public function get(string $paymentProductGroupId, GetProductgroupParams $query, ?CallContext $callContext = null): PaymentProductGroupResponse
93: {
94: $this->context['paymentProductGroupId'] = $paymentProductGroupId;
95: $responseClassMap = new ResponseClassMap();
96: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\PaymentProductGroupResponse';
97: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse';
98: try {
99: return $this->getCommunicator()->get(
100: $responseClassMap,
101: $this->instantiateUri('/v1/{merchantId}/productgroups/{paymentProductGroupId}'),
102: $this->getClientMetaInfo(),
103: $query,
104: $callContext
105: );
106: } catch (ErrorResponseException $e) {
107: throw $this->getResponseExceptionFactory()->createException(
108: $e->getHttpStatusCode(),
109: $e->getErrorResponse(),
110: $callContext
111: );
112: }
113: }
114:
115: /**
116: * Resource /{merchantId}/productgroups/{paymentProductGroupId}/deviceFingerprint - Get device fingerprint
117: *
118: * @param string $paymentProductGroupId
119: * @param DeviceFingerprintRequest $body
120: * @param CallContext|null $callContext
121: *
122: * @return DeviceFingerprintResponse
123: * @throws IdempotenceException
124: * @throws ValidationException
125: * @throws AuthorizationException
126: * @throws ReferenceException
127: * @throws PlatformException
128: * @throws ApiException
129: * @throws InvalidResponseException
130: * @link https://apireference.connect.worldline-solutions.com/s2sapi/v1/en_US/php/productgroups/deviceFingerprint.html Get device fingerprint
131: */
132: public function deviceFingerprint(string $paymentProductGroupId, DeviceFingerprintRequest $body, ?CallContext $callContext = null): DeviceFingerprintResponse
133: {
134: $this->context['paymentProductGroupId'] = $paymentProductGroupId;
135: $responseClassMap = new ResponseClassMap();
136: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\DeviceFingerprintResponse';
137: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse';
138: try {
139: return $this->getCommunicator()->post(
140: $responseClassMap,
141: $this->instantiateUri('/v1/{merchantId}/productgroups/{paymentProductGroupId}/deviceFingerprint'),
142: $this->getClientMetaInfo(),
143: $body,
144: null,
145: $callContext
146: );
147: } catch (ErrorResponseException $e) {
148: throw $this->getResponseExceptionFactory()->createException(
149: $e->getHttpStatusCode(),
150: $e->getErrorResponse(),
151: $callContext
152: );
153: }
154: }
155:
156: /**
157: * @return ExceptionFactory
158: */
159: private function getResponseExceptionFactory(): ExceptionFactory
160: {
161: if (is_null($this->responseExceptionFactory)) {
162: $this->responseExceptionFactory = new ExceptionFactory();
163: }
164: return $this->responseExceptionFactory;
165: }
166: }
167: