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 LineItem extends DataObject
15: {
16: /**
17: * @var AmountOfMoney|null
18: */
19: public ?AmountOfMoney $amountOfMoney = null;
20:
21: /**
22: * @var LineItemInvoiceData|null
23: */
24: public ?LineItemInvoiceData $invoiceData = null;
25:
26: /**
27: * @var LineItemLevel3InterchangeInformation|null
28: *
29: * @deprecated Use orderLineDetails instead
30: */
31: public ?LineItemLevel3InterchangeInformation $level3InterchangeInformation = null;
32:
33: /**
34: * @var OrderLineDetails|null
35: */
36: public ?OrderLineDetails $orderLineDetails = null;
37:
38: /**
39: * @return object
40: */
41: public function toObject(): object
42: {
43: $object = parent::toObject();
44: if (!is_null($this->amountOfMoney)) {
45: $object->amountOfMoney = $this->amountOfMoney->toObject();
46: }
47: if (!is_null($this->invoiceData)) {
48: $object->invoiceData = $this->invoiceData->toObject();
49: }
50: if (!is_null($this->level3InterchangeInformation)) {
51: $object->level3InterchangeInformation = $this->level3InterchangeInformation->toObject();
52: }
53: if (!is_null($this->orderLineDetails)) {
54: $object->orderLineDetails = $this->orderLineDetails->toObject();
55: }
56: return $object;
57: }
58:
59: /**
60: * @param object $object
61: *
62: * @return $this
63: * @throws UnexpectedValueException
64: */
65: public function fromObject(object $object): LineItem
66: {
67: parent::fromObject($object);
68: if (property_exists($object, 'amountOfMoney')) {
69: if (!is_object($object->amountOfMoney)) {
70: throw new UnexpectedValueException('value \'' . print_r($object->amountOfMoney, true) . '\' is not an object');
71: }
72: $value = new AmountOfMoney();
73: $this->amountOfMoney = $value->fromObject($object->amountOfMoney);
74: }
75: if (property_exists($object, 'invoiceData')) {
76: if (!is_object($object->invoiceData)) {
77: throw new UnexpectedValueException('value \'' . print_r($object->invoiceData, true) . '\' is not an object');
78: }
79: $value = new LineItemInvoiceData();
80: $this->invoiceData = $value->fromObject($object->invoiceData);
81: }
82: if (property_exists($object, 'level3InterchangeInformation')) {
83: if (!is_object($object->level3InterchangeInformation)) {
84: throw new UnexpectedValueException('value \'' . print_r($object->level3InterchangeInformation, true) . '\' is not an object');
85: }
86: $value = new LineItemLevel3InterchangeInformation();
87: $this->level3InterchangeInformation = $value->fromObject($object->level3InterchangeInformation);
88: }
89: if (property_exists($object, 'orderLineDetails')) {
90: if (!is_object($object->orderLineDetails)) {
91: throw new UnexpectedValueException('value \'' . print_r($object->orderLineDetails, true) . '\' is not an object');
92: }
93: $value = new OrderLineDetails();
94: $this->orderLineDetails = $value->fromObject($object->orderLineDetails);
95: }
96: return $this;
97: }
98: }
99: