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