| 1: | <?php |
| 2: | |
| 3: | |
| 4: | |
| 5: | |
| 6: | namespace Worldline\Connect\Sdk\V1\Domain; |
| 7: | |
| 8: | use UnexpectedValueException; |
| 9: | use Worldline\Connect\Sdk\Domain\DataObject; |
| 10: | |
| 11: | |
| 12: | |
| 13: | |
| 14: | class ShoppingCart extends DataObject |
| 15: | { |
| 16: | |
| 17: | |
| 18: | |
| 19: | public $amountBreakdown = null; |
| 20: | |
| 21: | |
| 22: | |
| 23: | |
| 24: | public $giftCardPurchase = null; |
| 25: | |
| 26: | |
| 27: | |
| 28: | |
| 29: | public $isPreOrder = null; |
| 30: | |
| 31: | |
| 32: | |
| 33: | |
| 34: | public $items = null; |
| 35: | |
| 36: | |
| 37: | |
| 38: | |
| 39: | public $preOrderItemAvailabilityDate = null; |
| 40: | |
| 41: | |
| 42: | |
| 43: | |
| 44: | public $reOrderIndicator = null; |
| 45: | |
| 46: | |
| 47: | |
| 48: | |
| 49: | public function toObject() |
| 50: | { |
| 51: | $object = parent::toObject(); |
| 52: | if (!is_null($this->amountBreakdown)) { |
| 53: | $object->amountBreakdown = []; |
| 54: | foreach ($this->amountBreakdown as $element) { |
| 55: | if (!is_null($element)) { |
| 56: | $object->amountBreakdown[] = $element->toObject(); |
| 57: | } |
| 58: | } |
| 59: | } |
| 60: | if (!is_null($this->giftCardPurchase)) { |
| 61: | $object->giftCardPurchase = $this->giftCardPurchase->toObject(); |
| 62: | } |
| 63: | if (!is_null($this->isPreOrder)) { |
| 64: | $object->isPreOrder = $this->isPreOrder; |
| 65: | } |
| 66: | if (!is_null($this->items)) { |
| 67: | $object->items = []; |
| 68: | foreach ($this->items as $element) { |
| 69: | if (!is_null($element)) { |
| 70: | $object->items[] = $element->toObject(); |
| 71: | } |
| 72: | } |
| 73: | } |
| 74: | if (!is_null($this->preOrderItemAvailabilityDate)) { |
| 75: | $object->preOrderItemAvailabilityDate = $this->preOrderItemAvailabilityDate; |
| 76: | } |
| 77: | if (!is_null($this->reOrderIndicator)) { |
| 78: | $object->reOrderIndicator = $this->reOrderIndicator; |
| 79: | } |
| 80: | return $object; |
| 81: | } |
| 82: | |
| 83: | |
| 84: | |
| 85: | |
| 86: | |
| 87: | |
| 88: | public function fromObject($object) |
| 89: | { |
| 90: | parent::fromObject($object); |
| 91: | if (property_exists($object, 'amountBreakdown')) { |
| 92: | if (!is_array($object->amountBreakdown) && !is_object($object->amountBreakdown)) { |
| 93: | throw new UnexpectedValueException('value \'' . print_r($object->amountBreakdown, true) . '\' is not an array or object'); |
| 94: | } |
| 95: | $this->amountBreakdown = []; |
| 96: | foreach ($object->amountBreakdown as $element) { |
| 97: | $value = new AmountBreakdown(); |
| 98: | $this->amountBreakdown[] = $value->fromObject($element); |
| 99: | } |
| 100: | } |
| 101: | if (property_exists($object, 'giftCardPurchase')) { |
| 102: | if (!is_object($object->giftCardPurchase)) { |
| 103: | throw new UnexpectedValueException('value \'' . print_r($object->giftCardPurchase, true) . '\' is not an object'); |
| 104: | } |
| 105: | $value = new GiftCardPurchase(); |
| 106: | $this->giftCardPurchase = $value->fromObject($object->giftCardPurchase); |
| 107: | } |
| 108: | if (property_exists($object, 'isPreOrder')) { |
| 109: | $this->isPreOrder = $object->isPreOrder; |
| 110: | } |
| 111: | if (property_exists($object, 'items')) { |
| 112: | if (!is_array($object->items) && !is_object($object->items)) { |
| 113: | throw new UnexpectedValueException('value \'' . print_r($object->items, true) . '\' is not an array or object'); |
| 114: | } |
| 115: | $this->items = []; |
| 116: | foreach ($object->items as $element) { |
| 117: | $value = new LineItem(); |
| 118: | $this->items[] = $value->fromObject($element); |
| 119: | } |
| 120: | } |
| 121: | if (property_exists($object, 'preOrderItemAvailabilityDate')) { |
| 122: | $this->preOrderItemAvailabilityDate = $object->preOrderItemAvailabilityDate; |
| 123: | } |
| 124: | if (property_exists($object, 'reOrderIndicator')) { |
| 125: | $this->reOrderIndicator = $object->reOrderIndicator; |
| 126: | } |
| 127: | return $this; |
| 128: | } |
| 129: | } |
| 130: | |