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\Installments;
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\GetInstallmentRequest;
16: use Worldline\Connect\Sdk\V1\Domain\InstallmentOptionsResponse;
17: use Worldline\Connect\Sdk\V1\ExceptionFactory;
18: use Worldline\Connect\Sdk\V1\IdempotenceException;
19: use Worldline\Connect\Sdk\V1\PlatformException;
20: use Worldline\Connect\Sdk\V1\ReferenceException;
21: use Worldline\Connect\Sdk\V1\ValidationException;
22:
23: /**
24: * Installments client.
25: *
26: * @package Worldline\Connect\Sdk\V1\Merchant\Installments
27: */
28: class InstallmentsClient extends ApiResource
29: {
30: /**
31: * @var ExceptionFactory|null
32: */
33: private ?ExceptionFactory $responseExceptionFactory = null;
34:
35: /**
36: * Resource /{merchantId}/installments/getInstallmentsInfo - Get installment information
37: *
38: * @param GetInstallmentRequest $body
39: * @param CallContext|null $callContext
40: *
41: * @return InstallmentOptionsResponse
42: * @throws IdempotenceException
43: * @throws ValidationException
44: * @throws AuthorizationException
45: * @throws ReferenceException
46: * @throws PlatformException
47: * @throws ApiException
48: * @throws InvalidResponseException
49: * @link https://apireference.connect.worldline-solutions.com/s2sapi/v1/en_US/php/installments/getInstallmentsInfo.html Get installment information
50: */
51: public function getInstallmentsInfo(GetInstallmentRequest $body, ?CallContext $callContext = null): InstallmentOptionsResponse
52: {
53: $responseClassMap = new ResponseClassMap();
54: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\InstallmentOptionsResponse';
55: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse';
56: try {
57: return $this->getCommunicator()->post(
58: $responseClassMap,
59: $this->instantiateUri('/v1/{merchantId}/installments/getInstallmentsInfo'),
60: $this->getClientMetaInfo(),
61: $body,
62: null,
63: $callContext
64: );
65: } catch (ErrorResponseException $e) {
66: throw $this->getResponseExceptionFactory()->createException(
67: $e->getHttpStatusCode(),
68: $e->getErrorResponse(),
69: $callContext
70: );
71: }
72: }
73:
74: /**
75: * @return ExceptionFactory
76: */
77: private function getResponseExceptionFactory(): ExceptionFactory
78: {
79: if (is_null($this->responseExceptionFactory)) {
80: $this->responseExceptionFactory = new ExceptionFactory();
81: }
82: return $this->responseExceptionFactory;
83: }
84: }
85: