| 1: | <?php |
| 2: | |
| 3: | |
| 4: | |
| 5: | namespace Worldline\Acquiring\Sdk\V1\Domain; |
| 6: | |
| 7: | use UnexpectedValueException; |
| 8: | use Worldline\Acquiring\Sdk\Domain\DataObject; |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | class PointOfSaleData extends DataObject |
| 14: | { |
| 15: | |
| 16: | |
| 17: | |
| 18: | public ?array $emvData = null; |
| 19: | |
| 20: | |
| 21: | |
| 22: | |
| 23: | public ?bool $isResponseToPinRequest = null; |
| 24: | |
| 25: | |
| 26: | |
| 27: | |
| 28: | public ?bool $isRetryWithTheSameOperationId = null; |
| 29: | |
| 30: | |
| 31: | |
| 32: | |
| 33: | public ?OnlinePinData $onlinePinData = null; |
| 34: | |
| 35: | |
| 36: | |
| 37: | |
| 38: | public ?string $track2Data = null; |
| 39: | |
| 40: | |
| 41: | |
| 42: | |
| 43: | public function toObject(): object |
| 44: | { |
| 45: | $object = parent::toObject(); |
| 46: | if (!is_null($this->emvData)) { |
| 47: | $object->emvData = []; |
| 48: | foreach ($this->emvData as $element) { |
| 49: | if (!is_null($element)) { |
| 50: | $object->emvData[] = $element->toObject(); |
| 51: | } |
| 52: | } |
| 53: | } |
| 54: | if (!is_null($this->isResponseToPinRequest)) { |
| 55: | $object->isResponseToPinRequest = $this->isResponseToPinRequest; |
| 56: | } |
| 57: | if (!is_null($this->isRetryWithTheSameOperationId)) { |
| 58: | $object->isRetryWithTheSameOperationId = $this->isRetryWithTheSameOperationId; |
| 59: | } |
| 60: | if (!is_null($this->onlinePinData)) { |
| 61: | $object->onlinePinData = $this->onlinePinData->toObject(); |
| 62: | } |
| 63: | if (!is_null($this->track2Data)) { |
| 64: | $object->track2Data = $this->track2Data; |
| 65: | } |
| 66: | return $object; |
| 67: | } |
| 68: | |
| 69: | |
| 70: | |
| 71: | |
| 72: | |
| 73: | |
| 74: | |
| 75: | public function fromObject(object $object): PointOfSaleData |
| 76: | { |
| 77: | parent::fromObject($object); |
| 78: | if (property_exists($object, 'emvData')) { |
| 79: | if (!is_array($object->emvData) && !is_object($object->emvData)) { |
| 80: | throw new UnexpectedValueException('value \'' . print_r($object->emvData, true) . '\' is not an array or object'); |
| 81: | } |
| 82: | $this->emvData = []; |
| 83: | foreach ($object->emvData as $element) { |
| 84: | $value = new EmvDataItem(); |
| 85: | $this->emvData[] = $value->fromObject($element); |
| 86: | } |
| 87: | } |
| 88: | if (property_exists($object, 'isResponseToPinRequest')) { |
| 89: | $this->isResponseToPinRequest = $object->isResponseToPinRequest; |
| 90: | } |
| 91: | if (property_exists($object, 'isRetryWithTheSameOperationId')) { |
| 92: | $this->isRetryWithTheSameOperationId = $object->isRetryWithTheSameOperationId; |
| 93: | } |
| 94: | if (property_exists($object, 'onlinePinData')) { |
| 95: | if (!is_object($object->onlinePinData)) { |
| 96: | throw new UnexpectedValueException('value \'' . print_r($object->onlinePinData, true) . '\' is not an object'); |
| 97: | } |
| 98: | $value = new OnlinePinData(); |
| 99: | $this->onlinePinData = $value->fromObject($object->onlinePinData); |
| 100: | } |
| 101: | if (property_exists($object, 'track2Data')) { |
| 102: | $this->track2Data = $object->track2Data; |
| 103: | } |
| 104: | return $this; |
| 105: | } |
| 106: | } |
| 107: | |