1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Pagantis\OrdersApiClient\Model\Order; |
4
|
|
|
|
5
|
|
|
use Pagantis\OrdersApiClient\Model\AbstractModel; |
6
|
|
|
use Pagantis\OrdersApiClient\Model\Order\User\Address; |
7
|
|
|
use Pagantis\OrdersApiClient\Model\Order\User\OrderHistory; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Class User |
11
|
|
|
* @package Pagantis\OrdersApiClient\Model\Order |
12
|
|
|
*/ |
13
|
|
|
class User extends AbstractModel |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* @var Address $address User address stored in merchant |
17
|
|
|
*/ |
18
|
|
|
protected $address; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @var Address $billingAddress Billing address for the order |
22
|
|
|
*/ |
23
|
|
|
protected $billingAddress; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var string $dateOfBirth 'YYYY-MM-DD' |
27
|
|
|
*/ |
28
|
|
|
protected $dateOfBirth; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var string $email User email. |
32
|
|
|
*/ |
33
|
|
|
protected $email; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @var string $fixPhone Fix Phone of the user |
37
|
|
|
*/ |
38
|
|
|
protected $fixPhone; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @var string $fullName Full name of the user including 2 surnames. |
42
|
|
|
*/ |
43
|
|
|
protected $fullName; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @var string $mobilePhone Mobile phone of the user |
47
|
|
|
*/ |
48
|
|
|
protected $mobilePhone; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @var string $taxId User Tax Id. |
52
|
|
|
*/ |
53
|
|
|
protected $taxId; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @var string $nationalId User National Id. |
57
|
|
|
*/ |
58
|
|
|
protected $nationalId; |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @var OrderHistory[] $orderHistory Array of previous orders |
62
|
|
|
*/ |
63
|
|
|
protected $orderHistory; |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @var Address $shippingAddress Shipping address of the order. |
67
|
|
|
*/ |
68
|
|
|
protected $shippingAddress; |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Not adding getters nor setters |
72
|
|
|
* |
73
|
|
|
* @deprecated |
74
|
|
|
*/ |
75
|
|
|
protected $truncated = false; |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* Configuration constructor. |
79
|
|
|
*/ |
80
|
|
|
public function __construct() |
81
|
|
|
{ |
82
|
|
|
$this->address = new Address(); |
83
|
|
|
$this->billingAddress = new Address(); |
84
|
|
|
$this->shippingAddress = new Address(); |
85
|
|
|
$this->orderHistory = array(); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @return Address |
90
|
|
|
*/ |
91
|
|
|
public function getAddress() |
92
|
|
|
{ |
93
|
|
|
return $this->address; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @param Address $address |
98
|
|
|
* |
99
|
|
|
* @return User |
100
|
|
|
*/ |
101
|
|
|
public function setAddress(Address $address) |
102
|
|
|
{ |
103
|
|
|
$this->address = $address; |
104
|
|
|
|
105
|
|
|
return $this; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @return Address |
110
|
|
|
*/ |
111
|
|
|
public function getBillingAddress() |
112
|
|
|
{ |
113
|
|
|
return $this->billingAddress; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* @param Address $billingAddress |
118
|
|
|
* |
119
|
|
|
* @return User |
120
|
|
|
*/ |
121
|
|
|
public function setBillingAddress(Address $billingAddress) |
122
|
|
|
{ |
123
|
|
|
$this->billingAddress = $billingAddress; |
124
|
|
|
|
125
|
|
|
return $this; |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* @return string |
130
|
|
|
*/ |
131
|
|
|
public function getDateOfBirth() |
132
|
|
|
{ |
133
|
|
|
return $this->dateOfBirth; |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* @param $dateOfBirth |
138
|
|
|
* |
139
|
|
|
* @return $this |
140
|
|
|
*/ |
141
|
|
|
public function setDateOfBirth($dateOfBirth) |
142
|
|
|
{ |
143
|
|
|
$this->dateOfBirth = $dateOfBirth; |
144
|
|
|
|
145
|
|
|
return $this; |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* @return string |
150
|
|
|
*/ |
151
|
|
|
public function getEmail() |
152
|
|
|
{ |
153
|
|
|
return $this->email; |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* @param $email |
158
|
|
|
* |
159
|
|
|
* @return $this |
160
|
|
|
*/ |
161
|
|
|
public function setEmail($email) |
162
|
|
|
{ |
163
|
|
|
$this->email = $email; |
164
|
|
|
|
165
|
|
|
return $this; |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
/** |
169
|
|
|
* @return string |
170
|
|
|
*/ |
171
|
|
|
public function getFixPhone() |
172
|
|
|
{ |
173
|
|
|
return $this->fixPhone; |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
/** |
177
|
|
|
* @param string $fixPhone |
178
|
|
|
* |
179
|
|
|
* @return User |
180
|
|
|
*/ |
181
|
|
|
public function setFixPhone($fixPhone) |
182
|
|
|
{ |
183
|
|
|
$this->fixPhone = $fixPhone; |
184
|
|
|
|
185
|
|
|
return $this; |
186
|
|
|
} |
187
|
|
|
|
188
|
|
|
/** |
189
|
|
|
* @return string |
190
|
|
|
*/ |
191
|
|
|
public function getFullName() |
192
|
|
|
{ |
193
|
|
|
return $this->fullName; |
194
|
|
|
} |
195
|
|
|
|
196
|
|
|
/** |
197
|
|
|
* @param $fullName |
198
|
|
|
* |
199
|
|
|
* @return $this |
200
|
|
|
*/ |
201
|
|
|
public function setFullName($fullName) |
202
|
|
|
{ |
203
|
|
|
$this->fullName = $fullName; |
204
|
|
|
|
205
|
|
|
return $this; |
206
|
|
|
} |
207
|
|
|
|
208
|
|
|
/** |
209
|
|
|
* @return string |
210
|
|
|
*/ |
211
|
|
|
public function getMobilePhone() |
212
|
|
|
{ |
213
|
|
|
return $this->mobilePhone; |
214
|
|
|
} |
215
|
|
|
|
216
|
|
|
/** |
217
|
|
|
* @param string $mobilePhone |
218
|
|
|
* |
219
|
|
|
* @return User |
220
|
|
|
*/ |
221
|
|
|
public function setMobilePhone($mobilePhone) |
222
|
|
|
{ |
223
|
|
|
$this->mobilePhone = $mobilePhone; |
224
|
|
|
|
225
|
|
|
return $this; |
226
|
|
|
} |
227
|
|
|
|
228
|
|
|
/** |
229
|
|
|
* @return string |
230
|
|
|
*/ |
231
|
|
|
public function getTaxId() |
232
|
|
|
{ |
233
|
|
|
return $this->taxId; |
234
|
|
|
} |
235
|
|
|
|
236
|
|
|
/** |
237
|
|
|
* @param string $taxId |
238
|
|
|
* |
239
|
|
|
* @return User |
240
|
|
|
*/ |
241
|
|
|
public function setTaxId($taxId) |
242
|
|
|
{ |
243
|
|
|
$this->taxId = $taxId; |
244
|
|
|
|
245
|
|
|
return $this; |
246
|
|
|
} |
247
|
|
|
|
248
|
|
|
/** |
249
|
|
|
* @return string |
250
|
|
|
*/ |
251
|
|
|
public function getNationalId() |
252
|
|
|
{ |
253
|
|
|
return $this->nationalId; |
254
|
|
|
} |
255
|
|
|
|
256
|
|
|
/** |
257
|
|
|
* @param string $nationalId |
258
|
|
|
* |
259
|
|
|
* @return User |
260
|
|
|
*/ |
261
|
|
|
public function setNationalId($nationalId) |
262
|
|
|
{ |
263
|
|
|
$this->nationalId = $nationalId; |
264
|
|
|
|
265
|
|
|
return $this; |
266
|
|
|
} |
267
|
|
|
|
268
|
|
|
/** |
269
|
|
|
* @return array |
270
|
|
|
*/ |
271
|
|
|
public function getOrderHistory() |
272
|
|
|
{ |
273
|
|
|
return $this->orderHistory; |
274
|
|
|
} |
275
|
|
|
|
276
|
|
|
/** |
277
|
|
|
* @param OrderHistory $orderHistory |
278
|
|
|
* |
279
|
|
|
* @return $this |
280
|
|
|
*/ |
281
|
|
|
public function addOrderHistory(OrderHistory $orderHistory) |
282
|
|
|
{ |
283
|
|
|
$this->orderHistory[] = $orderHistory; |
284
|
|
|
|
285
|
|
|
return $this; |
286
|
|
|
} |
287
|
|
|
|
288
|
|
|
/** |
289
|
|
|
* @return Address |
290
|
|
|
*/ |
291
|
|
|
public function getShippingAddress() |
292
|
|
|
{ |
293
|
|
|
return $this->shippingAddress; |
294
|
|
|
} |
295
|
|
|
|
296
|
|
|
/** |
297
|
|
|
* @param Address $shippingAddress |
298
|
|
|
* |
299
|
|
|
* @return User |
300
|
|
|
*/ |
301
|
|
|
public function setShippingAddress(Address $shippingAddress) |
302
|
|
|
{ |
303
|
|
|
$this->shippingAddress = $shippingAddress; |
304
|
|
|
|
305
|
|
|
return $this; |
306
|
|
|
} |
307
|
|
|
|
308
|
|
|
/** |
309
|
|
|
* Overwrite import to fill ordersHistory correctly |
310
|
|
|
* |
311
|
|
|
* @param \stdClass $object |
312
|
|
|
* @throws \Exception |
313
|
|
|
* |
314
|
|
|
*/ |
315
|
|
|
public function import($object) |
316
|
|
|
{ |
317
|
|
|
parent::import($object); |
318
|
|
|
$properties = get_object_vars($object); |
319
|
|
|
foreach ($properties as $key => $value) { |
320
|
|
|
if (is_array($value) && $key == 'order_history') { |
321
|
|
|
$this->orderHistory = array(); |
322
|
|
|
foreach ($value as $orderHistory) { |
323
|
|
|
$orderHistoryObject = new OrderHistory(); |
324
|
|
|
$orderHistoryObject->import($orderHistory); |
325
|
|
|
$this->addOrderHistory($orderHistoryObject); |
326
|
|
|
} |
327
|
|
|
} |
328
|
|
|
} |
329
|
|
|
} |
330
|
|
|
} |
331
|
|
|
|