| 1: | <?php |
| 2: | |
| 3: | |
| 4: | |
| 5: | |
| 6: | namespace Worldline\Connect\Sdk\V1\Merchant\Products; |
| 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\CreatePaymentProductSessionRequest; |
| 16: | use Worldline\Connect\Sdk\V1\Domain\CreatePaymentProductSessionResponse; |
| 17: | use Worldline\Connect\Sdk\V1\Domain\DeviceFingerprintRequest; |
| 18: | use Worldline\Connect\Sdk\V1\Domain\DeviceFingerprintResponse; |
| 19: | use Worldline\Connect\Sdk\V1\Domain\Directory; |
| 20: | use Worldline\Connect\Sdk\V1\Domain\GetCustomerDetailsRequest; |
| 21: | use Worldline\Connect\Sdk\V1\Domain\GetCustomerDetailsResponse; |
| 22: | use Worldline\Connect\Sdk\V1\Domain\PaymentProductNetworksResponse; |
| 23: | use Worldline\Connect\Sdk\V1\Domain\PaymentProductResponse; |
| 24: | use Worldline\Connect\Sdk\V1\Domain\PaymentProducts; |
| 25: | use Worldline\Connect\Sdk\V1\ExceptionFactory; |
| 26: | use Worldline\Connect\Sdk\V1\IdempotenceException; |
| 27: | use Worldline\Connect\Sdk\V1\PlatformException; |
| 28: | use Worldline\Connect\Sdk\V1\ReferenceException; |
| 29: | use Worldline\Connect\Sdk\V1\ValidationException; |
| 30: | |
| 31: | |
| 32: | |
| 33: | |
| 34: | |
| 35: | |
| 36: | class ProductsClient extends ApiResource |
| 37: | { |
| 38: | |
| 39: | |
| 40: | |
| 41: | private ?ExceptionFactory $responseExceptionFactory = null; |
| 42: | |
| 43: | |
| 44: | |
| 45: | |
| 46: | |
| 47: | |
| 48: | |
| 49: | |
| 50: | |
| 51: | |
| 52: | |
| 53: | |
| 54: | |
| 55: | |
| 56: | |
| 57: | |
| 58: | |
| 59: | public function find(FindProductsParams $query, ?CallContext $callContext = null): PaymentProducts |
| 60: | { |
| 61: | $responseClassMap = new ResponseClassMap(); |
| 62: | $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\PaymentProducts'; |
| 63: | $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse'; |
| 64: | try { |
| 65: | return $this->getCommunicator()->get( |
| 66: | $responseClassMap, |
| 67: | $this->instantiateUri('/v1/{merchantId}/products'), |
| 68: | $this->getClientMetaInfo(), |
| 69: | $query, |
| 70: | $callContext |
| 71: | ); |
| 72: | } catch (ErrorResponseException $e) { |
| 73: | throw $this->getResponseExceptionFactory()->createException( |
| 74: | $e->getHttpStatusCode(), |
| 75: | $e->getErrorResponse(), |
| 76: | $callContext |
| 77: | ); |
| 78: | } |
| 79: | } |
| 80: | |
| 81: | |
| 82: | |
| 83: | |
| 84: | |
| 85: | |
| 86: | |
| 87: | |
| 88: | |
| 89: | |
| 90: | |
| 91: | |
| 92: | |
| 93: | |
| 94: | |
| 95: | |
| 96: | |
| 97: | |
| 98: | public function get(int $paymentProductId, GetProductParams $query, ?CallContext $callContext = null): PaymentProductResponse |
| 99: | { |
| 100: | $this->context['paymentProductId'] = $paymentProductId; |
| 101: | $responseClassMap = new ResponseClassMap(); |
| 102: | $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\PaymentProductResponse'; |
| 103: | $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse'; |
| 104: | try { |
| 105: | return $this->getCommunicator()->get( |
| 106: | $responseClassMap, |
| 107: | $this->instantiateUri('/v1/{merchantId}/products/{paymentProductId}'), |
| 108: | $this->getClientMetaInfo(), |
| 109: | $query, |
| 110: | $callContext |
| 111: | ); |
| 112: | } catch (ErrorResponseException $e) { |
| 113: | throw $this->getResponseExceptionFactory()->createException( |
| 114: | $e->getHttpStatusCode(), |
| 115: | $e->getErrorResponse(), |
| 116: | $callContext |
| 117: | ); |
| 118: | } |
| 119: | } |
| 120: | |
| 121: | |
| 122: | |
| 123: | |
| 124: | |
| 125: | |
| 126: | |
| 127: | |
| 128: | |
| 129: | |
| 130: | |
| 131: | |
| 132: | |
| 133: | |
| 134: | |
| 135: | |
| 136: | |
| 137: | |
| 138: | public function directory(int $paymentProductId, DirectoryParams $query, ?CallContext $callContext = null): Directory |
| 139: | { |
| 140: | $this->context['paymentProductId'] = $paymentProductId; |
| 141: | $responseClassMap = new ResponseClassMap(); |
| 142: | $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\Directory'; |
| 143: | $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse'; |
| 144: | try { |
| 145: | return $this->getCommunicator()->get( |
| 146: | $responseClassMap, |
| 147: | $this->instantiateUri('/v1/{merchantId}/products/{paymentProductId}/directory'), |
| 148: | $this->getClientMetaInfo(), |
| 149: | $query, |
| 150: | $callContext |
| 151: | ); |
| 152: | } catch (ErrorResponseException $e) { |
| 153: | throw $this->getResponseExceptionFactory()->createException( |
| 154: | $e->getHttpStatusCode(), |
| 155: | $e->getErrorResponse(), |
| 156: | $callContext |
| 157: | ); |
| 158: | } |
| 159: | } |
| 160: | |
| 161: | |
| 162: | |
| 163: | |
| 164: | |
| 165: | |
| 166: | |
| 167: | |
| 168: | |
| 169: | |
| 170: | |
| 171: | |
| 172: | |
| 173: | |
| 174: | |
| 175: | |
| 176: | |
| 177: | |
| 178: | public function customerDetails(int $paymentProductId, GetCustomerDetailsRequest $body, ?CallContext $callContext = null): GetCustomerDetailsResponse |
| 179: | { |
| 180: | $this->context['paymentProductId'] = $paymentProductId; |
| 181: | $responseClassMap = new ResponseClassMap(); |
| 182: | $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\GetCustomerDetailsResponse'; |
| 183: | $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse'; |
| 184: | try { |
| 185: | return $this->getCommunicator()->post( |
| 186: | $responseClassMap, |
| 187: | $this->instantiateUri('/v1/{merchantId}/products/{paymentProductId}/customerDetails'), |
| 188: | $this->getClientMetaInfo(), |
| 189: | $body, |
| 190: | null, |
| 191: | $callContext |
| 192: | ); |
| 193: | } catch (ErrorResponseException $e) { |
| 194: | throw $this->getResponseExceptionFactory()->createException( |
| 195: | $e->getHttpStatusCode(), |
| 196: | $e->getErrorResponse(), |
| 197: | $callContext |
| 198: | ); |
| 199: | } |
| 200: | } |
| 201: | |
| 202: | |
| 203: | |
| 204: | |
| 205: | |
| 206: | |
| 207: | |
| 208: | |
| 209: | |
| 210: | |
| 211: | |
| 212: | |
| 213: | |
| 214: | |
| 215: | |
| 216: | |
| 217: | |
| 218: | |
| 219: | public function deviceFingerprint(int $paymentProductId, DeviceFingerprintRequest $body, ?CallContext $callContext = null): DeviceFingerprintResponse |
| 220: | { |
| 221: | $this->context['paymentProductId'] = $paymentProductId; |
| 222: | $responseClassMap = new ResponseClassMap(); |
| 223: | $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\DeviceFingerprintResponse'; |
| 224: | $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse'; |
| 225: | try { |
| 226: | return $this->getCommunicator()->post( |
| 227: | $responseClassMap, |
| 228: | $this->instantiateUri('/v1/{merchantId}/products/{paymentProductId}/deviceFingerprint'), |
| 229: | $this->getClientMetaInfo(), |
| 230: | $body, |
| 231: | null, |
| 232: | $callContext |
| 233: | ); |
| 234: | } catch (ErrorResponseException $e) { |
| 235: | throw $this->getResponseExceptionFactory()->createException( |
| 236: | $e->getHttpStatusCode(), |
| 237: | $e->getErrorResponse(), |
| 238: | $callContext |
| 239: | ); |
| 240: | } |
| 241: | } |
| 242: | |
| 243: | |
| 244: | |
| 245: | |
| 246: | |
| 247: | |
| 248: | |
| 249: | |
| 250: | |
| 251: | |
| 252: | |
| 253: | |
| 254: | |
| 255: | |
| 256: | |
| 257: | |
| 258: | |
| 259: | |
| 260: | public function networks(int $paymentProductId, NetworksParams $query, ?CallContext $callContext = null): PaymentProductNetworksResponse |
| 261: | { |
| 262: | $this->context['paymentProductId'] = $paymentProductId; |
| 263: | $responseClassMap = new ResponseClassMap(); |
| 264: | $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\PaymentProductNetworksResponse'; |
| 265: | $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse'; |
| 266: | try { |
| 267: | return $this->getCommunicator()->get( |
| 268: | $responseClassMap, |
| 269: | $this->instantiateUri('/v1/{merchantId}/products/{paymentProductId}/networks'), |
| 270: | $this->getClientMetaInfo(), |
| 271: | $query, |
| 272: | $callContext |
| 273: | ); |
| 274: | } catch (ErrorResponseException $e) { |
| 275: | throw $this->getResponseExceptionFactory()->createException( |
| 276: | $e->getHttpStatusCode(), |
| 277: | $e->getErrorResponse(), |
| 278: | $callContext |
| 279: | ); |
| 280: | } |
| 281: | } |
| 282: | |
| 283: | |
| 284: | |
| 285: | |
| 286: | |
| 287: | |
| 288: | |
| 289: | |
| 290: | |
| 291: | |
| 292: | |
| 293: | |
| 294: | |
| 295: | |
| 296: | |
| 297: | |
| 298: | |
| 299: | |
| 300: | public function sessions(int $paymentProductId, CreatePaymentProductSessionRequest $body, ?CallContext $callContext = null): CreatePaymentProductSessionResponse |
| 301: | { |
| 302: | $this->context['paymentProductId'] = $paymentProductId; |
| 303: | $responseClassMap = new ResponseClassMap(); |
| 304: | $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\CreatePaymentProductSessionResponse'; |
| 305: | $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse'; |
| 306: | try { |
| 307: | return $this->getCommunicator()->post( |
| 308: | $responseClassMap, |
| 309: | $this->instantiateUri('/v1/{merchantId}/products/{paymentProductId}/sessions'), |
| 310: | $this->getClientMetaInfo(), |
| 311: | $body, |
| 312: | null, |
| 313: | $callContext |
| 314: | ); |
| 315: | } catch (ErrorResponseException $e) { |
| 316: | throw $this->getResponseExceptionFactory()->createException( |
| 317: | $e->getHttpStatusCode(), |
| 318: | $e->getErrorResponse(), |
| 319: | $callContext |
| 320: | ); |
| 321: | } |
| 322: | } |
| 323: | |
| 324: | |
| 325: | |
| 326: | |
| 327: | private function getResponseExceptionFactory(): ExceptionFactory |
| 328: | { |
| 329: | if (is_null($this->responseExceptionFactory)) { |
| 330: | $this->responseExceptionFactory = new ExceptionFactory(); |
| 331: | } |
| 332: | return $this->responseExceptionFactory; |
| 333: | } |
| 334: | } |
| 335: | |