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