1: <?php
2: /*
3: * This class was auto-generated from the API references found at
4: * https://apireference.connect.worldline-solutions.com/
5: */
6: namespace Worldline\Connect\Sdk\V1\Domain;
7:
8: use UnexpectedValueException;
9: use Worldline\Connect\Sdk\Domain\DataObject;
10:
11: /**
12: * @package Worldline\Connect\Sdk\V1\Domain
13: */
14: class ShoppingCart extends DataObject
15: {
16: /**
17: * @var AmountBreakdown[]|null
18: */
19: public ?array $amountBreakdown = null;
20:
21: /**
22: * @var GiftCardPurchase|null
23: */
24: public ?GiftCardPurchase $giftCardPurchase = null;
25:
26: /**
27: * @var bool|null
28: */
29: public ?bool $isPreOrder = null;
30:
31: /**
32: * @var LineItem[]|null
33: */
34: public ?array $items = null;
35:
36: /**
37: * @var string|null
38: */
39: public ?string $preOrderItemAvailabilityDate = null;
40:
41: /**
42: * @var bool|null
43: */
44: public ?bool $reOrderIndicator = null;
45:
46: /**
47: * @return object
48: */
49: public function toObject(): object
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: * @param object $object
85: *
86: * @return $this
87: * @throws UnexpectedValueException
88: */
89: public function fromObject(object $object): ShoppingCart
90: {
91: parent::fromObject($object);
92: if (property_exists($object, 'amountBreakdown')) {
93: if (!is_array($object->amountBreakdown) && !is_object($object->amountBreakdown)) {
94: throw new UnexpectedValueException('value \'' . print_r($object->amountBreakdown, true) . '\' is not an array or object');
95: }
96: $this->amountBreakdown = [];
97: foreach ($object->amountBreakdown as $element) {
98: $value = new AmountBreakdown();
99: $this->amountBreakdown[] = $value->fromObject($element);
100: }
101: }
102: if (property_exists($object, 'giftCardPurchase')) {
103: if (!is_object($object->giftCardPurchase)) {
104: throw new UnexpectedValueException('value \'' . print_r($object->giftCardPurchase, true) . '\' is not an object');
105: }
106: $value = new GiftCardPurchase();
107: $this->giftCardPurchase = $value->fromObject($object->giftCardPurchase);
108: }
109: if (property_exists($object, 'isPreOrder')) {
110: $this->isPreOrder = $object->isPreOrder;
111: }
112: if (property_exists($object, 'items')) {
113: if (!is_array($object->items) && !is_object($object->items)) {
114: throw new UnexpectedValueException('value \'' . print_r($object->items, true) . '\' is not an array or object');
115: }
116: $this->items = [];
117: foreach ($object->items as $element) {
118: $value = new LineItem();
119: $this->items[] = $value->fromObject($element);
120: }
121: }
122: if (property_exists($object, 'preOrderItemAvailabilityDate')) {
123: $this->preOrderItemAvailabilityDate = $object->preOrderItemAvailabilityDate;
124: }
125: if (property_exists($object, 'reOrderIndicator')) {
126: $this->reOrderIndicator = $object->reOrderIndicator;
127: }
128: return $this;
129: }
130: }
131: