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