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