1: <?php
2: /*
3: * This file was automatically generated.
4: */
5: namespace Worldline\Acquiring\Sdk\V1\Acquirer\Merchant\Technicalreversals;
6:
7: use Worldline\Acquiring\Sdk\ApiResource;
8: use Worldline\Acquiring\Sdk\CallContext;
9: use Worldline\Acquiring\Sdk\Communication\ErrorResponseException;
10: use Worldline\Acquiring\Sdk\Communication\InvalidResponseException;
11: use Worldline\Acquiring\Sdk\Communication\ResponseClassMap;
12: use Worldline\Acquiring\Sdk\V1\ApiException;
13: use Worldline\Acquiring\Sdk\V1\AuthorizationException;
14: use Worldline\Acquiring\Sdk\V1\Domain\ApiTechnicalReversalRequest;
15: use Worldline\Acquiring\Sdk\V1\Domain\ApiTechnicalReversalResponse;
16: use Worldline\Acquiring\Sdk\V1\ExceptionFactory;
17: use Worldline\Acquiring\Sdk\V1\PlatformException;
18: use Worldline\Acquiring\Sdk\V1\ReferenceException;
19: use Worldline\Acquiring\Sdk\V1\ValidationException;
20:
21: /**
22: * TechnicalReversals client.
23: *
24: * @package Worldline\Acquiring\Sdk\V1\Acquirer\Merchant\Technicalreversals
25: */
26: class TechnicalReversalsClient extends ApiResource
27: {
28: /**
29: * @var ExceptionFactory|null
30: */
31: private ?ExceptionFactory $responseExceptionFactory = null;
32:
33: /**
34: * Resource /processing/v1/{acquirerId}/{merchantId}/operations/{operationId}/reverse - Technical reversal
35: *
36: * @param string $operationId
37: * @param ApiTechnicalReversalRequest $body
38: * @param CallContext|null $callContext
39: *
40: * @return ApiTechnicalReversalResponse
41: * @throws ValidationException
42: * @throws AuthorizationException
43: * @throws ReferenceException
44: * @throws PlatformException
45: * @throws ApiException
46: * @throws InvalidResponseException
47: * @link https://docs.acquiring.worldline-solutions.com/api-reference#tag/Technical-Reversals/operation/technicalReversal Technical reversal
48: */
49: public function technicalReversal(string $operationId, ApiTechnicalReversalRequest $body, ?CallContext $callContext = null): ApiTechnicalReversalResponse
50: {
51: $this->context['operationId'] = $operationId;
52: $responseClassMap = new ResponseClassMap();
53: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Acquiring\Sdk\V1\Domain\ApiTechnicalReversalResponse';
54: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Acquiring\Sdk\V1\Domain\ApiPaymentErrorResponse';
55: try {
56: return $this->getCommunicator()->post(
57: $responseClassMap,
58: $this->instantiateUri('/processing/v1/{acquirerId}/{merchantId}/operations/{operationId}/reverse'),
59: $body,
60: null,
61: $callContext
62: );
63: } catch (ErrorResponseException $e) {
64: throw $this->getResponseExceptionFactory()->createException(
65: $e->getHttpStatusCode(),
66: $e->getErrorResponse(),
67: $callContext
68: );
69: }
70: }
71:
72: /**
73: * @return ExceptionFactory
74: */
75: private function getResponseExceptionFactory(): ExceptionFactory
76: {
77: if (is_null($this->responseExceptionFactory)) {
78: $this->responseExceptionFactory = new ExceptionFactory();
79: }
80: return $this->responseExceptionFactory;
81: }
82: }
83: