| 1: | <?php |
| 2: | |
| 3: | |
| 4: | |
| 5: | namespace Worldline\Acquiring\Sdk\V1\Domain; |
| 6: | |
| 7: | use DateTime; |
| 8: | use UnexpectedValueException; |
| 9: | use Worldline\Acquiring\Sdk\Domain\DataObject; |
| 10: | |
| 11: | |
| 12: | |
| 13: | |
| 14: | class ApiPaymentRequest extends DataObject |
| 15: | { |
| 16: | |
| 17: | |
| 18: | |
| 19: | public ?AmountData $amount = null; |
| 20: | |
| 21: | |
| 22: | |
| 23: | |
| 24: | public ?AmountBreakdownData $amountBreakdownData = null; |
| 25: | |
| 26: | |
| 27: | |
| 28: | |
| 29: | public ?string $authorizationType = null; |
| 30: | |
| 31: | |
| 32: | |
| 33: | |
| 34: | public ?CardPaymentData $cardPaymentData = null; |
| 35: | |
| 36: | |
| 37: | |
| 38: | |
| 39: | public ?DccData $dynamicCurrencyConversion = null; |
| 40: | |
| 41: | |
| 42: | |
| 43: | |
| 44: | public ?MerchantData $merchant = null; |
| 45: | |
| 46: | |
| 47: | |
| 48: | |
| 49: | public ?string $operationId = null; |
| 50: | |
| 51: | |
| 52: | |
| 53: | |
| 54: | public ?PaymentReferences $references = null; |
| 55: | |
| 56: | |
| 57: | |
| 58: | |
| 59: | public ?TerminalData $terminalData = null; |
| 60: | |
| 61: | |
| 62: | |
| 63: | |
| 64: | public ?DateTime $transactionTimestamp = null; |
| 65: | |
| 66: | |
| 67: | |
| 68: | |
| 69: | public function toObject(): object |
| 70: | { |
| 71: | $object = parent::toObject(); |
| 72: | if (!is_null($this->amount)) { |
| 73: | $object->amount = $this->amount->toObject(); |
| 74: | } |
| 75: | if (!is_null($this->amountBreakdownData)) { |
| 76: | $object->amountBreakdownData = $this->amountBreakdownData->toObject(); |
| 77: | } |
| 78: | if (!is_null($this->authorizationType)) { |
| 79: | $object->authorizationType = $this->authorizationType; |
| 80: | } |
| 81: | if (!is_null($this->cardPaymentData)) { |
| 82: | $object->cardPaymentData = $this->cardPaymentData->toObject(); |
| 83: | } |
| 84: | if (!is_null($this->dynamicCurrencyConversion)) { |
| 85: | $object->dynamicCurrencyConversion = $this->dynamicCurrencyConversion->toObject(); |
| 86: | } |
| 87: | if (!is_null($this->merchant)) { |
| 88: | $object->merchant = $this->merchant->toObject(); |
| 89: | } |
| 90: | if (!is_null($this->operationId)) { |
| 91: | $object->operationId = $this->operationId; |
| 92: | } |
| 93: | if (!is_null($this->references)) { |
| 94: | $object->references = $this->references->toObject(); |
| 95: | } |
| 96: | if (!is_null($this->terminalData)) { |
| 97: | $object->terminalData = $this->terminalData->toObject(); |
| 98: | } |
| 99: | if (!is_null($this->transactionTimestamp)) { |
| 100: | $object->transactionTimestamp = $this->transactionTimestamp->format('Y-m-d\\TH:i:s.vP'); |
| 101: | } |
| 102: | return $object; |
| 103: | } |
| 104: | |
| 105: | |
| 106: | |
| 107: | |
| 108: | |
| 109: | |
| 110: | |
| 111: | public function fromObject(object $object): ApiPaymentRequest |
| 112: | { |
| 113: | parent::fromObject($object); |
| 114: | if (property_exists($object, 'amount')) { |
| 115: | if (!is_object($object->amount)) { |
| 116: | throw new UnexpectedValueException('value \'' . print_r($object->amount, true) . '\' is not an object'); |
| 117: | } |
| 118: | $value = new AmountData(); |
| 119: | $this->amount = $value->fromObject($object->amount); |
| 120: | } |
| 121: | if (property_exists($object, 'amountBreakdownData')) { |
| 122: | if (!is_object($object->amountBreakdownData)) { |
| 123: | throw new UnexpectedValueException('value \'' . print_r($object->amountBreakdownData, true) . '\' is not an object'); |
| 124: | } |
| 125: | $value = new AmountBreakdownData(); |
| 126: | $this->amountBreakdownData = $value->fromObject($object->amountBreakdownData); |
| 127: | } |
| 128: | if (property_exists($object, 'authorizationType')) { |
| 129: | $this->authorizationType = $object->authorizationType; |
| 130: | } |
| 131: | if (property_exists($object, 'cardPaymentData')) { |
| 132: | if (!is_object($object->cardPaymentData)) { |
| 133: | throw new UnexpectedValueException('value \'' . print_r($object->cardPaymentData, true) . '\' is not an object'); |
| 134: | } |
| 135: | $value = new CardPaymentData(); |
| 136: | $this->cardPaymentData = $value->fromObject($object->cardPaymentData); |
| 137: | } |
| 138: | if (property_exists($object, 'dynamicCurrencyConversion')) { |
| 139: | if (!is_object($object->dynamicCurrencyConversion)) { |
| 140: | throw new UnexpectedValueException('value \'' . print_r($object->dynamicCurrencyConversion, true) . '\' is not an object'); |
| 141: | } |
| 142: | $value = new DccData(); |
| 143: | $this->dynamicCurrencyConversion = $value->fromObject($object->dynamicCurrencyConversion); |
| 144: | } |
| 145: | if (property_exists($object, 'merchant')) { |
| 146: | if (!is_object($object->merchant)) { |
| 147: | throw new UnexpectedValueException('value \'' . print_r($object->merchant, true) . '\' is not an object'); |
| 148: | } |
| 149: | $value = new MerchantData(); |
| 150: | $this->merchant = $value->fromObject($object->merchant); |
| 151: | } |
| 152: | if (property_exists($object, 'operationId')) { |
| 153: | $this->operationId = $object->operationId; |
| 154: | } |
| 155: | if (property_exists($object, 'references')) { |
| 156: | if (!is_object($object->references)) { |
| 157: | throw new UnexpectedValueException('value \'' . print_r($object->references, true) . '\' is not an object'); |
| 158: | } |
| 159: | $value = new PaymentReferences(); |
| 160: | $this->references = $value->fromObject($object->references); |
| 161: | } |
| 162: | if (property_exists($object, 'terminalData')) { |
| 163: | if (!is_object($object->terminalData)) { |
| 164: | throw new UnexpectedValueException('value \'' . print_r($object->terminalData, true) . '\' is not an object'); |
| 165: | } |
| 166: | $value = new TerminalData(); |
| 167: | $this->terminalData = $value->fromObject($object->terminalData); |
| 168: | } |
| 169: | if (property_exists($object, 'transactionTimestamp')) { |
| 170: | $this->transactionTimestamp = new DateTime($object->transactionTimestamp); |
| 171: | } |
| 172: | return $this; |
| 173: | } |
| 174: | } |
| 175: | |