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\Mandates;
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\CreateMandateRequest;
16: use Worldline\Connect\Sdk\V1\Domain\CreateMandateResponse;
17: use Worldline\Connect\Sdk\V1\Domain\GetMandateResponse;
18: use Worldline\Connect\Sdk\V1\ExceptionFactory;
19: use Worldline\Connect\Sdk\V1\IdempotenceException;
20: use Worldline\Connect\Sdk\V1\PlatformException;
21: use Worldline\Connect\Sdk\V1\ReferenceException;
22: use Worldline\Connect\Sdk\V1\ValidationException;
23:
24: /**
25: * Mandates client.
26: */
27: class MandatesClient extends ApiResource
28: {
29: /** @var ExceptionFactory|null */
30: private $responseExceptionFactory = null;
31:
32: /**
33: * Resource /{merchantId}/mandates - Create mandate
34: *
35: * @param CreateMandateRequest $body
36: * @param CallContext $callContext
37: * @return CreateMandateResponse
38: *
39: * @throws IdempotenceException
40: * @throws ValidationException
41: * @throws AuthorizationException
42: * @throws ReferenceException
43: * @throws PlatformException
44: * @throws ApiException
45: * @throws InvalidResponseException
46: * @link https://apireference.connect.worldline-solutions.com/s2sapi/v1/en_US/php/mandates/create.html Create mandate
47: */
48: public function create(CreateMandateRequest $body, CallContext $callContext = null)
49: {
50: $responseClassMap = new ResponseClassMap();
51: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\CreateMandateResponse';
52: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse';
53: try {
54: return $this->getCommunicator()->post(
55: $responseClassMap,
56: $this->instantiateUri('/v1/{merchantId}/mandates'),
57: $this->getClientMetaInfo(),
58: $body,
59: null,
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}/mandates/{uniqueMandateReference} - Create mandate with mandatereference
73: *
74: * @param string $uniqueMandateReference
75: * @param CreateMandateRequest $body
76: * @param CallContext $callContext
77: * @return CreateMandateResponse
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/mandates/createWithMandateReference.html Create mandate with mandatereference
87: */
88: public function createWithMandateReference($uniqueMandateReference, CreateMandateRequest $body, CallContext $callContext = null)
89: {
90: $this->context['uniqueMandateReference'] = $uniqueMandateReference;
91: $responseClassMap = new ResponseClassMap();
92: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\CreateMandateResponse';
93: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse';
94: try {
95: return $this->getCommunicator()->put(
96: $responseClassMap,
97: $this->instantiateUri('/v1/{merchantId}/mandates/{uniqueMandateReference}'),
98: $this->getClientMetaInfo(),
99: $body,
100: null,
101: $callContext
102: );
103: } catch (ErrorResponseException $e) {
104: throw $this->getResponseExceptionFactory()->createException(
105: $e->getHttpStatusCode(),
106: $e->getErrorResponse(),
107: $callContext
108: );
109: }
110: }
111:
112: /**
113: * Resource /{merchantId}/mandates/{uniqueMandateReference} - Get mandate
114: *
115: * @param string $uniqueMandateReference
116: * @param CallContext $callContext
117: * @return GetMandateResponse
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/mandates/get.html Get mandate
127: */
128: public function get($uniqueMandateReference, CallContext $callContext = null)
129: {
130: $this->context['uniqueMandateReference'] = $uniqueMandateReference;
131: $responseClassMap = new ResponseClassMap();
132: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\GetMandateResponse';
133: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse';
134: try {
135: return $this->getCommunicator()->get(
136: $responseClassMap,
137: $this->instantiateUri('/v1/{merchantId}/mandates/{uniqueMandateReference}'),
138: $this->getClientMetaInfo(),
139: null,
140: $callContext
141: );
142: } catch (ErrorResponseException $e) {
143: throw $this->getResponseExceptionFactory()->createException(
144: $e->getHttpStatusCode(),
145: $e->getErrorResponse(),
146: $callContext
147: );
148: }
149: }
150:
151: /**
152: * Resource /{merchantId}/mandates/{uniqueMandateReference}/block - Block mandate
153: *
154: * @param string $uniqueMandateReference
155: * @param CallContext $callContext
156: * @return GetMandateResponse
157: *
158: * @throws IdempotenceException
159: * @throws ValidationException
160: * @throws AuthorizationException
161: * @throws ReferenceException
162: * @throws PlatformException
163: * @throws ApiException
164: * @throws InvalidResponseException
165: * @link https://apireference.connect.worldline-solutions.com/s2sapi/v1/en_US/php/mandates/block.html Block mandate
166: */
167: public function block($uniqueMandateReference, CallContext $callContext = null)
168: {
169: $this->context['uniqueMandateReference'] = $uniqueMandateReference;
170: $responseClassMap = new ResponseClassMap();
171: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\GetMandateResponse';
172: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse';
173: try {
174: return $this->getCommunicator()->post(
175: $responseClassMap,
176: $this->instantiateUri('/v1/{merchantId}/mandates/{uniqueMandateReference}/block'),
177: $this->getClientMetaInfo(),
178: null,
179: null,
180: $callContext
181: );
182: } catch (ErrorResponseException $e) {
183: throw $this->getResponseExceptionFactory()->createException(
184: $e->getHttpStatusCode(),
185: $e->getErrorResponse(),
186: $callContext
187: );
188: }
189: }
190:
191: /**
192: * Resource /{merchantId}/mandates/{uniqueMandateReference}/unblock - Unblock mandate
193: *
194: * @param string $uniqueMandateReference
195: * @param CallContext $callContext
196: * @return GetMandateResponse
197: *
198: * @throws IdempotenceException
199: * @throws ValidationException
200: * @throws AuthorizationException
201: * @throws ReferenceException
202: * @throws PlatformException
203: * @throws ApiException
204: * @throws InvalidResponseException
205: * @link https://apireference.connect.worldline-solutions.com/s2sapi/v1/en_US/php/mandates/unblock.html Unblock mandate
206: */
207: public function unblock($uniqueMandateReference, CallContext $callContext = null)
208: {
209: $this->context['uniqueMandateReference'] = $uniqueMandateReference;
210: $responseClassMap = new ResponseClassMap();
211: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\GetMandateResponse';
212: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse';
213: try {
214: return $this->getCommunicator()->post(
215: $responseClassMap,
216: $this->instantiateUri('/v1/{merchantId}/mandates/{uniqueMandateReference}/unblock'),
217: $this->getClientMetaInfo(),
218: null,
219: null,
220: $callContext
221: );
222: } catch (ErrorResponseException $e) {
223: throw $this->getResponseExceptionFactory()->createException(
224: $e->getHttpStatusCode(),
225: $e->getErrorResponse(),
226: $callContext
227: );
228: }
229: }
230:
231: /**
232: * Resource /{merchantId}/mandates/{uniqueMandateReference}/revoke - Revoke mandate
233: *
234: * @param string $uniqueMandateReference
235: * @param CallContext $callContext
236: * @return GetMandateResponse
237: *
238: * @throws IdempotenceException
239: * @throws ValidationException
240: * @throws AuthorizationException
241: * @throws ReferenceException
242: * @throws PlatformException
243: * @throws ApiException
244: * @throws InvalidResponseException
245: * @link https://apireference.connect.worldline-solutions.com/s2sapi/v1/en_US/php/mandates/revoke.html Revoke mandate
246: */
247: public function revoke($uniqueMandateReference, CallContext $callContext = null)
248: {
249: $this->context['uniqueMandateReference'] = $uniqueMandateReference;
250: $responseClassMap = new ResponseClassMap();
251: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\GetMandateResponse';
252: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse';
253: try {
254: return $this->getCommunicator()->post(
255: $responseClassMap,
256: $this->instantiateUri('/v1/{merchantId}/mandates/{uniqueMandateReference}/revoke'),
257: $this->getClientMetaInfo(),
258: null,
259: null,
260: $callContext
261: );
262: } catch (ErrorResponseException $e) {
263: throw $this->getResponseExceptionFactory()->createException(
264: $e->getHttpStatusCode(),
265: $e->getErrorResponse(),
266: $callContext
267: );
268: }
269: }
270:
271: /** @return ExceptionFactory */
272: private function getResponseExceptionFactory()
273: {
274: if (is_null($this->responseExceptionFactory)) {
275: $this->responseExceptionFactory = new ExceptionFactory();
276: }
277: return $this->responseExceptionFactory;
278: }
279: }
280: