1: | <?php |
2: | |
3: | |
4: | |
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: | |
27: | |
28: | class ProductgroupsClient extends ApiResource |
29: | { |
30: | |
31: | private $responseExceptionFactory = null; |
32: | |
33: | |
34: | |
35: | |
36: | |
37: | |
38: | |
39: | |
40: | |
41: | |
42: | |
43: | |
44: | |
45: | |
46: | |
47: | |
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: | |
73: | |
74: | |
75: | |
76: | |
77: | |
78: | |
79: | |
80: | |
81: | |
82: | |
83: | |
84: | |
85: | |
86: | |
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: | |
113: | |
114: | |
115: | |
116: | |
117: | |
118: | |
119: | |
120: | |
121: | |
122: | |
123: | |
124: | |
125: | |
126: | |
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: | |
153: | private function getResponseExceptionFactory() |
154: | { |
155: | if (is_null($this->responseExceptionFactory)) { |
156: | $this->responseExceptionFactory = new ExceptionFactory(); |
157: | } |
158: | return $this->responseExceptionFactory; |
159: | } |
160: | } |
161: | |