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:
10: /**
11: * @package Worldline\Connect\Sdk\V1\Domain
12: */
13: class Customer extends CustomerBase
14: {
15: /**
16: * @var CustomerAccount|null
17: */
18: public ?CustomerAccount $account = null;
19:
20: /**
21: * @var string|null
22: */
23: public ?string $accountType = null;
24:
25: /**
26: * @var Address|null
27: */
28: public ?Address $billingAddress = null;
29:
30: /**
31: * @var ContactDetails|null
32: */
33: public ?ContactDetails $contactDetails = null;
34:
35: /**
36: * @var CustomerDevice|null
37: */
38: public ?CustomerDevice $device = null;
39:
40: /**
41: * @var string|null
42: */
43: public ?string $fiscalNumber = null;
44:
45: /**
46: * @var bool|null
47: */
48: public ?bool $isCompany = null;
49:
50: /**
51: * @var bool|null
52: */
53: public ?bool $isPreviousCustomer = null;
54:
55: /**
56: * @var string|null
57: */
58: public ?string $locale = null;
59:
60: /**
61: * @var PersonalInformation|null
62: */
63: public ?PersonalInformation $personalInformation = null;
64:
65: /**
66: * @var AddressPersonal|null
67: *
68: * @deprecated Use Order.shipping.address instead
69: */
70: public ?AddressPersonal $shippingAddress = null;
71:
72: /**
73: * @return object
74: */
75: public function toObject(): object
76: {
77: $object = parent::toObject();
78: if (!is_null($this->account)) {
79: $object->account = $this->account->toObject();
80: }
81: if (!is_null($this->accountType)) {
82: $object->accountType = $this->accountType;
83: }
84: if (!is_null($this->billingAddress)) {
85: $object->billingAddress = $this->billingAddress->toObject();
86: }
87: if (!is_null($this->contactDetails)) {
88: $object->contactDetails = $this->contactDetails->toObject();
89: }
90: if (!is_null($this->device)) {
91: $object->device = $this->device->toObject();
92: }
93: if (!is_null($this->fiscalNumber)) {
94: $object->fiscalNumber = $this->fiscalNumber;
95: }
96: if (!is_null($this->isCompany)) {
97: $object->isCompany = $this->isCompany;
98: }
99: if (!is_null($this->isPreviousCustomer)) {
100: $object->isPreviousCustomer = $this->isPreviousCustomer;
101: }
102: if (!is_null($this->locale)) {
103: $object->locale = $this->locale;
104: }
105: if (!is_null($this->personalInformation)) {
106: $object->personalInformation = $this->personalInformation->toObject();
107: }
108: if (!is_null($this->shippingAddress)) {
109: $object->shippingAddress = $this->shippingAddress->toObject();
110: }
111: return $object;
112: }
113:
114: /**
115: * @param object $object
116: *
117: * @return $this
118: * @throws UnexpectedValueException
119: */
120: public function fromObject(object $object): Customer
121: {
122: parent::fromObject($object);
123: if (property_exists($object, 'account')) {
124: if (!is_object($object->account)) {
125: throw new UnexpectedValueException('value \'' . print_r($object->account, true) . '\' is not an object');
126: }
127: $value = new CustomerAccount();
128: $this->account = $value->fromObject($object->account);
129: }
130: if (property_exists($object, 'accountType')) {
131: $this->accountType = $object->accountType;
132: }
133: if (property_exists($object, 'billingAddress')) {
134: if (!is_object($object->billingAddress)) {
135: throw new UnexpectedValueException('value \'' . print_r($object->billingAddress, true) . '\' is not an object');
136: }
137: $value = new Address();
138: $this->billingAddress = $value->fromObject($object->billingAddress);
139: }
140: if (property_exists($object, 'contactDetails')) {
141: if (!is_object($object->contactDetails)) {
142: throw new UnexpectedValueException('value \'' . print_r($object->contactDetails, true) . '\' is not an object');
143: }
144: $value = new ContactDetails();
145: $this->contactDetails = $value->fromObject($object->contactDetails);
146: }
147: if (property_exists($object, 'device')) {
148: if (!is_object($object->device)) {
149: throw new UnexpectedValueException('value \'' . print_r($object->device, true) . '\' is not an object');
150: }
151: $value = new CustomerDevice();
152: $this->device = $value->fromObject($object->device);
153: }
154: if (property_exists($object, 'fiscalNumber')) {
155: $this->fiscalNumber = $object->fiscalNumber;
156: }
157: if (property_exists($object, 'isCompany')) {
158: $this->isCompany = $object->isCompany;
159: }
160: if (property_exists($object, 'isPreviousCustomer')) {
161: $this->isPreviousCustomer = $object->isPreviousCustomer;
162: }
163: if (property_exists($object, 'locale')) {
164: $this->locale = $object->locale;
165: }
166: if (property_exists($object, 'personalInformation')) {
167: if (!is_object($object->personalInformation)) {
168: throw new UnexpectedValueException('value \'' . print_r($object->personalInformation, true) . '\' is not an object');
169: }
170: $value = new PersonalInformation();
171: $this->personalInformation = $value->fromObject($object->personalInformation);
172: }
173: if (property_exists($object, 'shippingAddress')) {
174: if (!is_object($object->shippingAddress)) {
175: throw new UnexpectedValueException('value \'' . print_r($object->shippingAddress, true) . '\' is not an object');
176: }
177: $value = new AddressPersonal();
178: $this->shippingAddress = $value->fromObject($object->shippingAddress);
179: }
180: return $this;
181: }
182: }
183: