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\Hostedmandatemanagements;
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\CreateHostedMandateManagementRequest;
16: use Worldline\Connect\Sdk\V1\Domain\CreateHostedMandateManagementResponse;
17: use Worldline\Connect\Sdk\V1\Domain\GetHostedMandateManagementResponse;
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: * Hosted Mandate Management client.
26: */
27: class HostedmandatemanagementsClient extends ApiResource
28: {
29: /** @var ExceptionFactory|null */
30: private $responseExceptionFactory = null;
31:
32: /**
33: * Resource /{merchantId}/hostedmandatemanagements - Create hosted mandate management
34: *
35: * @param CreateHostedMandateManagementRequest $body
36: * @param CallContext $callContext
37: * @return CreateHostedMandateManagementResponse
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/hostedmandatemanagements/create.html Create hosted mandate management
47: */
48: public function create(CreateHostedMandateManagementRequest $body, CallContext $callContext = null)
49: {
50: $responseClassMap = new ResponseClassMap();
51: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\CreateHostedMandateManagementResponse';
52: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse';
53: try {
54: return $this->getCommunicator()->post(
55: $responseClassMap,
56: $this->instantiateUri('/v1/{merchantId}/hostedmandatemanagements'),
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}/hostedmandatemanagements/{hostedMandateManagementId} - Get hosted mandate management status
73: *
74: * @param string $hostedMandateManagementId
75: * @param CallContext $callContext
76: * @return GetHostedMandateManagementResponse
77: *
78: * @throws IdempotenceException
79: * @throws ValidationException
80: * @throws AuthorizationException
81: * @throws ReferenceException
82: * @throws PlatformException
83: * @throws ApiException
84: * @throws InvalidResponseException
85: * @link https://apireference.connect.worldline-solutions.com/s2sapi/v1/en_US/php/hostedmandatemanagements/get.html Get hosted mandate management status
86: */
87: public function get($hostedMandateManagementId, CallContext $callContext = null)
88: {
89: $this->context['hostedMandateManagementId'] = $hostedMandateManagementId;
90: $responseClassMap = new ResponseClassMap();
91: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\GetHostedMandateManagementResponse';
92: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse';
93: try {
94: return $this->getCommunicator()->get(
95: $responseClassMap,
96: $this->instantiateUri('/v1/{merchantId}/hostedmandatemanagements/{hostedMandateManagementId}'),
97: $this->getClientMetaInfo(),
98: null,
99: $callContext
100: );
101: } catch (ErrorResponseException $e) {
102: throw $this->getResponseExceptionFactory()->createException(
103: $e->getHttpStatusCode(),
104: $e->getErrorResponse(),
105: $callContext
106: );
107: }
108: }
109:
110: /** @return ExceptionFactory */
111: private function getResponseExceptionFactory()
112: {
113: if (is_null($this->responseExceptionFactory)) {
114: $this->responseExceptionFactory = new ExceptionFactory();
115: }
116: return $this->responseExceptionFactory;
117: }
118: }
119: