| 1: | <?php |
| 2: | |
| 3: | |
| 4: | |
| 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: | |
| 25: | |
| 26: | class InstallmentsClient extends ApiResource |
| 27: | { |
| 28: | |
| 29: | private $responseExceptionFactory = null; |
| 30: | |
| 31: | |
| 32: | |
| 33: | |
| 34: | |
| 35: | |
| 36: | |
| 37: | |
| 38: | |
| 39: | |
| 40: | |
| 41: | |
| 42: | |
| 43: | |
| 44: | |
| 45: | |
| 46: | |
| 47: | public function getInstallmentsInfo(GetInstallmentRequest $body, CallContext $callContext = null) |
| 48: | { |
| 49: | $responseClassMap = new ResponseClassMap(); |
| 50: | $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\InstallmentOptionsResponse'; |
| 51: | $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse'; |
| 52: | try { |
| 53: | return $this->getCommunicator()->post( |
| 54: | $responseClassMap, |
| 55: | $this->instantiateUri('/v1/{merchantId}/installments/getInstallmentsInfo'), |
| 56: | $this->getClientMetaInfo(), |
| 57: | $body, |
| 58: | null, |
| 59: | $callContext |
| 60: | ); |
| 61: | } catch (ErrorResponseException $e) { |
| 62: | throw $this->getResponseExceptionFactory()->createException( |
| 63: | $e->getHttpStatusCode(), |
| 64: | $e->getErrorResponse(), |
| 65: | $callContext |
| 66: | ); |
| 67: | } |
| 68: | } |
| 69: | |
| 70: | |
| 71: | private function getResponseExceptionFactory() |
| 72: | { |
| 73: | if (is_null($this->responseExceptionFactory)) { |
| 74: | $this->responseExceptionFactory = new ExceptionFactory(); |
| 75: | } |
| 76: | return $this->responseExceptionFactory; |
| 77: | } |
| 78: | } |
| 79: | |