| 1: | <?php |
| 2: | |
| 3: | |
| 4: | |
| 5: | |
| 6: | namespace Worldline\Connect\Sdk\V1\Merchant\Mandates; |
| 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\CreateMandateRequest; |
| 16: | use Worldline\Connect\Sdk\V1\Domain\CreateMandateResponse; |
| 17: | use Worldline\Connect\Sdk\V1\Domain\GetMandateResponse; |
| 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: | |
| 26: | |
| 27: | |
| 28: | |
| 29: | class MandatesClient extends ApiResource |
| 30: | { |
| 31: | |
| 32: | |
| 33: | |
| 34: | private ?ExceptionFactory $responseExceptionFactory = null; |
| 35: | |
| 36: | |
| 37: | |
| 38: | |
| 39: | |
| 40: | |
| 41: | |
| 42: | |
| 43: | |
| 44: | |
| 45: | |
| 46: | |
| 47: | |
| 48: | |
| 49: | |
| 50: | |
| 51: | |
| 52: | public function create(CreateMandateRequest $body, ?CallContext $callContext = null): CreateMandateResponse |
| 53: | { |
| 54: | $responseClassMap = new ResponseClassMap(); |
| 55: | $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\CreateMandateResponse'; |
| 56: | $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse'; |
| 57: | try { |
| 58: | return $this->getCommunicator()->post( |
| 59: | $responseClassMap, |
| 60: | $this->instantiateUri('/v1/{merchantId}/mandates'), |
| 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: | |
| 77: | |
| 78: | |
| 79: | |
| 80: | |
| 81: | |
| 82: | |
| 83: | |
| 84: | |
| 85: | |
| 86: | |
| 87: | |
| 88: | |
| 89: | |
| 90: | |
| 91: | |
| 92: | public function createWithMandateReference(string $uniqueMandateReference, CreateMandateRequest $body, ?CallContext $callContext = null): CreateMandateResponse |
| 93: | { |
| 94: | $this->context['uniqueMandateReference'] = $uniqueMandateReference; |
| 95: | $responseClassMap = new ResponseClassMap(); |
| 96: | $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\CreateMandateResponse'; |
| 97: | $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse'; |
| 98: | try { |
| 99: | return $this->getCommunicator()->put( |
| 100: | $responseClassMap, |
| 101: | $this->instantiateUri('/v1/{merchantId}/mandates/{uniqueMandateReference}'), |
| 102: | $this->getClientMetaInfo(), |
| 103: | $body, |
| 104: | null, |
| 105: | $callContext |
| 106: | ); |
| 107: | } catch (ErrorResponseException $e) { |
| 108: | throw $this->getResponseExceptionFactory()->createException( |
| 109: | $e->getHttpStatusCode(), |
| 110: | $e->getErrorResponse(), |
| 111: | $callContext |
| 112: | ); |
| 113: | } |
| 114: | } |
| 115: | |
| 116: | |
| 117: | |
| 118: | |
| 119: | |
| 120: | |
| 121: | |
| 122: | |
| 123: | |
| 124: | |
| 125: | |
| 126: | |
| 127: | |
| 128: | |
| 129: | |
| 130: | |
| 131: | |
| 132: | public function get(string $uniqueMandateReference, ?CallContext $callContext = null): GetMandateResponse |
| 133: | { |
| 134: | $this->context['uniqueMandateReference'] = $uniqueMandateReference; |
| 135: | $responseClassMap = new ResponseClassMap(); |
| 136: | $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\GetMandateResponse'; |
| 137: | $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse'; |
| 138: | try { |
| 139: | return $this->getCommunicator()->get( |
| 140: | $responseClassMap, |
| 141: | $this->instantiateUri('/v1/{merchantId}/mandates/{uniqueMandateReference}'), |
| 142: | $this->getClientMetaInfo(), |
| 143: | null, |
| 144: | $callContext |
| 145: | ); |
| 146: | } catch (ErrorResponseException $e) { |
| 147: | throw $this->getResponseExceptionFactory()->createException( |
| 148: | $e->getHttpStatusCode(), |
| 149: | $e->getErrorResponse(), |
| 150: | $callContext |
| 151: | ); |
| 152: | } |
| 153: | } |
| 154: | |
| 155: | |
| 156: | |
| 157: | |
| 158: | |
| 159: | |
| 160: | |
| 161: | |
| 162: | |
| 163: | |
| 164: | |
| 165: | |
| 166: | |
| 167: | |
| 168: | |
| 169: | |
| 170: | |
| 171: | public function block(string $uniqueMandateReference, ?CallContext $callContext = null): GetMandateResponse |
| 172: | { |
| 173: | $this->context['uniqueMandateReference'] = $uniqueMandateReference; |
| 174: | $responseClassMap = new ResponseClassMap(); |
| 175: | $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\GetMandateResponse'; |
| 176: | $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse'; |
| 177: | try { |
| 178: | return $this->getCommunicator()->post( |
| 179: | $responseClassMap, |
| 180: | $this->instantiateUri('/v1/{merchantId}/mandates/{uniqueMandateReference}/block'), |
| 181: | $this->getClientMetaInfo(), |
| 182: | null, |
| 183: | null, |
| 184: | $callContext |
| 185: | ); |
| 186: | } catch (ErrorResponseException $e) { |
| 187: | throw $this->getResponseExceptionFactory()->createException( |
| 188: | $e->getHttpStatusCode(), |
| 189: | $e->getErrorResponse(), |
| 190: | $callContext |
| 191: | ); |
| 192: | } |
| 193: | } |
| 194: | |
| 195: | |
| 196: | |
| 197: | |
| 198: | |
| 199: | |
| 200: | |
| 201: | |
| 202: | |
| 203: | |
| 204: | |
| 205: | |
| 206: | |
| 207: | |
| 208: | |
| 209: | |
| 210: | |
| 211: | public function unblock(string $uniqueMandateReference, ?CallContext $callContext = null): GetMandateResponse |
| 212: | { |
| 213: | $this->context['uniqueMandateReference'] = $uniqueMandateReference; |
| 214: | $responseClassMap = new ResponseClassMap(); |
| 215: | $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\GetMandateResponse'; |
| 216: | $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse'; |
| 217: | try { |
| 218: | return $this->getCommunicator()->post( |
| 219: | $responseClassMap, |
| 220: | $this->instantiateUri('/v1/{merchantId}/mandates/{uniqueMandateReference}/unblock'), |
| 221: | $this->getClientMetaInfo(), |
| 222: | null, |
| 223: | null, |
| 224: | $callContext |
| 225: | ); |
| 226: | } catch (ErrorResponseException $e) { |
| 227: | throw $this->getResponseExceptionFactory()->createException( |
| 228: | $e->getHttpStatusCode(), |
| 229: | $e->getErrorResponse(), |
| 230: | $callContext |
| 231: | ); |
| 232: | } |
| 233: | } |
| 234: | |
| 235: | |
| 236: | |
| 237: | |
| 238: | |
| 239: | |
| 240: | |
| 241: | |
| 242: | |
| 243: | |
| 244: | |
| 245: | |
| 246: | |
| 247: | |
| 248: | |
| 249: | |
| 250: | |
| 251: | public function revoke(string $uniqueMandateReference, ?CallContext $callContext = null): GetMandateResponse |
| 252: | { |
| 253: | $this->context['uniqueMandateReference'] = $uniqueMandateReference; |
| 254: | $responseClassMap = new ResponseClassMap(); |
| 255: | $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\GetMandateResponse'; |
| 256: | $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse'; |
| 257: | try { |
| 258: | return $this->getCommunicator()->post( |
| 259: | $responseClassMap, |
| 260: | $this->instantiateUri('/v1/{merchantId}/mandates/{uniqueMandateReference}/revoke'), |
| 261: | $this->getClientMetaInfo(), |
| 262: | null, |
| 263: | null, |
| 264: | $callContext |
| 265: | ); |
| 266: | } catch (ErrorResponseException $e) { |
| 267: | throw $this->getResponseExceptionFactory()->createException( |
| 268: | $e->getHttpStatusCode(), |
| 269: | $e->getErrorResponse(), |
| 270: | $callContext |
| 271: | ); |
| 272: | } |
| 273: | } |
| 274: | |
| 275: | |
| 276: | |
| 277: | |
| 278: | private function getResponseExceptionFactory(): ExceptionFactory |
| 279: | { |
| 280: | if (is_null($this->responseExceptionFactory)) { |
| 281: | $this->responseExceptionFactory = new ExceptionFactory(); |
| 282: | } |
| 283: | return $this->responseExceptionFactory; |
| 284: | } |
| 285: | } |
| 286: | |