| 1: | <?php |
| 2: | |
| 3: | |
| 4: | |
| 5: | |
| 6: | namespace Worldline\Connect\Sdk\V1\Merchant\Disputes; |
| 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\DisputeResponse; |
| 16: | use Worldline\Connect\Sdk\V1\Domain\UploadDisputeFileResponse; |
| 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: | |
| 27: | |
| 28: | class DisputesClient extends ApiResource |
| 29: | { |
| 30: | |
| 31: | |
| 32: | |
| 33: | private ?ExceptionFactory $responseExceptionFactory = null; |
| 34: | |
| 35: | |
| 36: | |
| 37: | |
| 38: | |
| 39: | |
| 40: | |
| 41: | |
| 42: | |
| 43: | |
| 44: | |
| 45: | |
| 46: | |
| 47: | |
| 48: | |
| 49: | |
| 50: | |
| 51: | public function get(string $disputeId, ?CallContext $callContext = null): DisputeResponse |
| 52: | { |
| 53: | $this->context['disputeId'] = $disputeId; |
| 54: | $responseClassMap = new ResponseClassMap(); |
| 55: | $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\DisputeResponse'; |
| 56: | $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse'; |
| 57: | try { |
| 58: | return $this->getCommunicator()->get( |
| 59: | $responseClassMap, |
| 60: | $this->instantiateUri('/v1/{merchantId}/disputes/{disputeId}'), |
| 61: | $this->getClientMetaInfo(), |
| 62: | null, |
| 63: | $callContext |
| 64: | ); |
| 65: | } catch (ErrorResponseException $e) { |
| 66: | throw $this->getResponseExceptionFactory()->createException( |
| 67: | $e->getHttpStatusCode(), |
| 68: | $e->getErrorResponse(), |
| 69: | $callContext |
| 70: | ); |
| 71: | } |
| 72: | } |
| 73: | |
| 74: | |
| 75: | |
| 76: | |
| 77: | |
| 78: | |
| 79: | |
| 80: | |
| 81: | |
| 82: | |
| 83: | |
| 84: | |
| 85: | |
| 86: | |
| 87: | |
| 88: | |
| 89: | |
| 90: | public function submit(string $disputeId, ?CallContext $callContext = null): DisputeResponse |
| 91: | { |
| 92: | $this->context['disputeId'] = $disputeId; |
| 93: | $responseClassMap = new ResponseClassMap(); |
| 94: | $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\DisputeResponse'; |
| 95: | $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse'; |
| 96: | try { |
| 97: | return $this->getCommunicator()->post( |
| 98: | $responseClassMap, |
| 99: | $this->instantiateUri('/v1/{merchantId}/disputes/{disputeId}/submit'), |
| 100: | $this->getClientMetaInfo(), |
| 101: | null, |
| 102: | null, |
| 103: | $callContext |
| 104: | ); |
| 105: | } catch (ErrorResponseException $e) { |
| 106: | throw $this->getResponseExceptionFactory()->createException( |
| 107: | $e->getHttpStatusCode(), |
| 108: | $e->getErrorResponse(), |
| 109: | $callContext |
| 110: | ); |
| 111: | } |
| 112: | } |
| 113: | |
| 114: | |
| 115: | |
| 116: | |
| 117: | |
| 118: | |
| 119: | |
| 120: | |
| 121: | |
| 122: | |
| 123: | |
| 124: | |
| 125: | |
| 126: | |
| 127: | |
| 128: | |
| 129: | |
| 130: | public function cancel(string $disputeId, ?CallContext $callContext = null): DisputeResponse |
| 131: | { |
| 132: | $this->context['disputeId'] = $disputeId; |
| 133: | $responseClassMap = new ResponseClassMap(); |
| 134: | $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\DisputeResponse'; |
| 135: | $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse'; |
| 136: | try { |
| 137: | return $this->getCommunicator()->post( |
| 138: | $responseClassMap, |
| 139: | $this->instantiateUri('/v1/{merchantId}/disputes/{disputeId}/cancel'), |
| 140: | $this->getClientMetaInfo(), |
| 141: | null, |
| 142: | null, |
| 143: | $callContext |
| 144: | ); |
| 145: | } catch (ErrorResponseException $e) { |
| 146: | throw $this->getResponseExceptionFactory()->createException( |
| 147: | $e->getHttpStatusCode(), |
| 148: | $e->getErrorResponse(), |
| 149: | $callContext |
| 150: | ); |
| 151: | } |
| 152: | } |
| 153: | |
| 154: | |
| 155: | |
| 156: | |
| 157: | |
| 158: | |
| 159: | |
| 160: | |
| 161: | |
| 162: | |
| 163: | |
| 164: | |
| 165: | |
| 166: | |
| 167: | |
| 168: | |
| 169: | |
| 170: | |
| 171: | public function uploadFile(string $disputeId, UploadFileRequest $body, ?CallContext $callContext = null): UploadDisputeFileResponse |
| 172: | { |
| 173: | $this->context['disputeId'] = $disputeId; |
| 174: | $responseClassMap = new ResponseClassMap(); |
| 175: | $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\UploadDisputeFileResponse'; |
| 176: | $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse'; |
| 177: | try { |
| 178: | return $this->getCommunicator()->post( |
| 179: | $responseClassMap, |
| 180: | $this->instantiateUri('/files/v1/{merchantId}/disputes/{disputeId}'), |
| 181: | $this->getClientMetaInfo(), |
| 182: | $body, |
| 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: | private function getResponseExceptionFactory(): ExceptionFactory |
| 199: | { |
| 200: | if (is_null($this->responseExceptionFactory)) { |
| 201: | $this->responseExceptionFactory = new ExceptionFactory(); |
| 202: | } |
| 203: | return $this->responseExceptionFactory; |
| 204: | } |
| 205: | } |
| 206: | |