| 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 ApiPaymentResource extends DataObject |
| 15: | { |
| 16: | |
| 17: | |
| 18: | |
| 19: | public $cardPaymentData = null; |
| 20: | |
| 21: | |
| 22: | |
| 23: | |
| 24: | public $initialAuthorizationCode = null; |
| 25: | |
| 26: | |
| 27: | |
| 28: | |
| 29: | public $operations = null; |
| 30: | |
| 31: | |
| 32: | |
| 33: | |
| 34: | public $paymentId = null; |
| 35: | |
| 36: | |
| 37: | |
| 38: | |
| 39: | public $references = null; |
| 40: | |
| 41: | |
| 42: | |
| 43: | |
| 44: | public $status = null; |
| 45: | |
| 46: | |
| 47: | |
| 48: | |
| 49: | public $statusTimestamp = null; |
| 50: | |
| 51: | |
| 52: | |
| 53: | |
| 54: | public $totalAuthorizedAmount = null; |
| 55: | |
| 56: | |
| 57: | |
| 58: | |
| 59: | public function toObject() |
| 60: | { |
| 61: | $object = parent::toObject(); |
| 62: | if (!is_null($this->cardPaymentData)) { |
| 63: | $object->cardPaymentData = $this->cardPaymentData->toObject(); |
| 64: | } |
| 65: | if (!is_null($this->initialAuthorizationCode)) { |
| 66: | $object->initialAuthorizationCode = $this->initialAuthorizationCode; |
| 67: | } |
| 68: | if (!is_null($this->operations)) { |
| 69: | $object->operations = []; |
| 70: | foreach ($this->operations as $element) { |
| 71: | if (!is_null($element)) { |
| 72: | $object->operations[] = $element->toObject(); |
| 73: | } |
| 74: | } |
| 75: | } |
| 76: | if (!is_null($this->paymentId)) { |
| 77: | $object->paymentId = $this->paymentId; |
| 78: | } |
| 79: | if (!is_null($this->references)) { |
| 80: | $object->references = $this->references->toObject(); |
| 81: | } |
| 82: | if (!is_null($this->status)) { |
| 83: | $object->status = $this->status; |
| 84: | } |
| 85: | if (!is_null($this->statusTimestamp)) { |
| 86: | $object->statusTimestamp = $this->statusTimestamp->format('Y-m-d\\TH:i:s.vP'); |
| 87: | } |
| 88: | if (!is_null($this->totalAuthorizedAmount)) { |
| 89: | $object->totalAuthorizedAmount = $this->totalAuthorizedAmount->toObject(); |
| 90: | } |
| 91: | return $object; |
| 92: | } |
| 93: | |
| 94: | |
| 95: | |
| 96: | |
| 97: | |
| 98: | |
| 99: | public function fromObject($object) |
| 100: | { |
| 101: | parent::fromObject($object); |
| 102: | if (property_exists($object, 'cardPaymentData')) { |
| 103: | if (!is_object($object->cardPaymentData)) { |
| 104: | throw new UnexpectedValueException('value \'' . print_r($object->cardPaymentData, true) . '\' is not an object'); |
| 105: | } |
| 106: | $value = new CardPaymentDataForResource(); |
| 107: | $this->cardPaymentData = $value->fromObject($object->cardPaymentData); |
| 108: | } |
| 109: | if (property_exists($object, 'initialAuthorizationCode')) { |
| 110: | $this->initialAuthorizationCode = $object->initialAuthorizationCode; |
| 111: | } |
| 112: | if (property_exists($object, 'operations')) { |
| 113: | if (!is_array($object->operations) && !is_object($object->operations)) { |
| 114: | throw new UnexpectedValueException('value \'' . print_r($object->operations, true) . '\' is not an array or object'); |
| 115: | } |
| 116: | $this->operations = []; |
| 117: | foreach ($object->operations as $element) { |
| 118: | $value = new SubOperation(); |
| 119: | $this->operations[] = $value->fromObject($element); |
| 120: | } |
| 121: | } |
| 122: | if (property_exists($object, 'paymentId')) { |
| 123: | $this->paymentId = $object->paymentId; |
| 124: | } |
| 125: | if (property_exists($object, 'references')) { |
| 126: | if (!is_object($object->references)) { |
| 127: | throw new UnexpectedValueException('value \'' . print_r($object->references, true) . '\' is not an object'); |
| 128: | } |
| 129: | $value = new ApiReferencesForResponses(); |
| 130: | $this->references = $value->fromObject($object->references); |
| 131: | } |
| 132: | if (property_exists($object, 'status')) { |
| 133: | $this->status = $object->status; |
| 134: | } |
| 135: | if (property_exists($object, 'statusTimestamp')) { |
| 136: | $this->statusTimestamp = new DateTime($object->statusTimestamp); |
| 137: | } |
| 138: | if (property_exists($object, 'totalAuthorizedAmount')) { |
| 139: | if (!is_object($object->totalAuthorizedAmount)) { |
| 140: | throw new UnexpectedValueException('value \'' . print_r($object->totalAuthorizedAmount, true) . '\' is not an object'); |
| 141: | } |
| 142: | $value = new AmountData(); |
| 143: | $this->totalAuthorizedAmount = $value->fromObject($object->totalAuthorizedAmount); |
| 144: | } |
| 145: | return $this; |
| 146: | } |
| 147: | } |
| 148: | |