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 Order extends DataObject
15: {
16: /**
17: * @var AdditionalOrderInput|null
18: */
19: public ?AdditionalOrderInput $additionalInput = null;
20:
21: /**
22: * @var AmountOfMoney|null
23: */
24: public ?AmountOfMoney $amountOfMoney = null;
25:
26: /**
27: * @var Customer|null
28: */
29: public ?Customer $customer = null;
30:
31: /**
32: * @var LineItem[]|null
33: *
34: * @deprecated Use shoppingCart.items instead
35: */
36: public ?array $items = null;
37:
38: /**
39: * @var OrderReferences|null
40: */
41: public ?OrderReferences $references = null;
42:
43: /**
44: * @var Seller|null
45: *
46: * @deprecated Use Merchant.seller instead
47: */
48: public ?Seller $seller = null;
49:
50: /**
51: * @var Shipping|null
52: */
53: public ?Shipping $shipping = null;
54:
55: /**
56: * @var ShoppingCart|null
57: */
58: public ?ShoppingCart $shoppingCart = null;
59:
60: /**
61: * @return object
62: */
63: public function toObject(): object
64: {
65: $object = parent::toObject();
66: if (!is_null($this->additionalInput)) {
67: $object->additionalInput = $this->additionalInput->toObject();
68: }
69: if (!is_null($this->amountOfMoney)) {
70: $object->amountOfMoney = $this->amountOfMoney->toObject();
71: }
72: if (!is_null($this->customer)) {
73: $object->customer = $this->customer->toObject();
74: }
75: if (!is_null($this->items)) {
76: $object->items = [];
77: foreach ($this->items as $element) {
78: if (!is_null($element)) {
79: $object->items[] = $element->toObject();
80: }
81: }
82: }
83: if (!is_null($this->references)) {
84: $object->references = $this->references->toObject();
85: }
86: if (!is_null($this->seller)) {
87: $object->seller = $this->seller->toObject();
88: }
89: if (!is_null($this->shipping)) {
90: $object->shipping = $this->shipping->toObject();
91: }
92: if (!is_null($this->shoppingCart)) {
93: $object->shoppingCart = $this->shoppingCart->toObject();
94: }
95: return $object;
96: }
97:
98: /**
99: * @param object $object
100: *
101: * @return $this
102: * @throws UnexpectedValueException
103: */
104: public function fromObject(object $object): Order
105: {
106: parent::fromObject($object);
107: if (property_exists($object, 'additionalInput')) {
108: if (!is_object($object->additionalInput)) {
109: throw new UnexpectedValueException('value \'' . print_r($object->additionalInput, true) . '\' is not an object');
110: }
111: $value = new AdditionalOrderInput();
112: $this->additionalInput = $value->fromObject($object->additionalInput);
113: }
114: if (property_exists($object, 'amountOfMoney')) {
115: if (!is_object($object->amountOfMoney)) {
116: throw new UnexpectedValueException('value \'' . print_r($object->amountOfMoney, true) . '\' is not an object');
117: }
118: $value = new AmountOfMoney();
119: $this->amountOfMoney = $value->fromObject($object->amountOfMoney);
120: }
121: if (property_exists($object, 'customer')) {
122: if (!is_object($object->customer)) {
123: throw new UnexpectedValueException('value \'' . print_r($object->customer, true) . '\' is not an object');
124: }
125: $value = new Customer();
126: $this->customer = $value->fromObject($object->customer);
127: }
128: if (property_exists($object, 'items')) {
129: if (!is_array($object->items) && !is_object($object->items)) {
130: throw new UnexpectedValueException('value \'' . print_r($object->items, true) . '\' is not an array or object');
131: }
132: $this->items = [];
133: foreach ($object->items as $element) {
134: $value = new LineItem();
135: $this->items[] = $value->fromObject($element);
136: }
137: }
138: if (property_exists($object, 'references')) {
139: if (!is_object($object->references)) {
140: throw new UnexpectedValueException('value \'' . print_r($object->references, true) . '\' is not an object');
141: }
142: $value = new OrderReferences();
143: $this->references = $value->fromObject($object->references);
144: }
145: if (property_exists($object, 'seller')) {
146: if (!is_object($object->seller)) {
147: throw new UnexpectedValueException('value \'' . print_r($object->seller, true) . '\' is not an object');
148: }
149: $value = new Seller();
150: $this->seller = $value->fromObject($object->seller);
151: }
152: if (property_exists($object, 'shipping')) {
153: if (!is_object($object->shipping)) {
154: throw new UnexpectedValueException('value \'' . print_r($object->shipping, true) . '\' is not an object');
155: }
156: $value = new Shipping();
157: $this->shipping = $value->fromObject($object->shipping);
158: }
159: if (property_exists($object, 'shoppingCart')) {
160: if (!is_object($object->shoppingCart)) {
161: throw new UnexpectedValueException('value \'' . print_r($object->shoppingCart, true) . '\' is not an object');
162: }
163: $value = new ShoppingCart();
164: $this->shoppingCart = $value->fromObject($object->shoppingCart);
165: }
166: return $this;
167: }
168: }
169: