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 $dni ID of the user |
32
|
|
|
*/ |
33
|
|
|
protected $dni; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @var string $email User email. |
37
|
|
|
*/ |
38
|
|
|
protected $email; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @var string $fixPhone Fix Phone of the user |
42
|
|
|
*/ |
43
|
|
|
protected $fixPhone; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @var string $fullName Full name of the user including 2 surnames. |
47
|
|
|
*/ |
48
|
|
|
protected $fullName; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @var string $mobilePhone Mobile phone of the user |
52
|
|
|
*/ |
53
|
|
|
protected $mobilePhone; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @var OrderHistory[] $orderHistory Array of previous orders |
57
|
|
|
*/ |
58
|
|
|
protected $orderHistory; |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @var Address $shippingAddress Shipping address of the order. |
62
|
|
|
*/ |
63
|
|
|
protected $shippingAddress; |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Not adding getters nor setters |
67
|
|
|
* |
68
|
|
|
* @deprecated |
69
|
|
|
*/ |
70
|
|
|
protected $truncated = false; |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Configuration constructor. |
74
|
|
|
*/ |
75
|
|
|
public function __construct() |
76
|
|
|
{ |
77
|
|
|
$this->address = new Address(); |
78
|
|
|
$this->billingAddress = new Address(); |
79
|
|
|
$this->shippingAddress = new Address(); |
80
|
|
|
$this->orderHistory = array(); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @return Address |
85
|
|
|
*/ |
86
|
|
|
public function getAddress() |
87
|
|
|
{ |
88
|
|
|
return $this->address; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @param Address $address |
93
|
|
|
* |
94
|
|
|
* @return User |
95
|
|
|
*/ |
96
|
|
|
public function setAddress(Address $address) |
97
|
|
|
{ |
98
|
|
|
$this->address = $address; |
99
|
|
|
|
100
|
|
|
return $this; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* @return Address |
105
|
|
|
*/ |
106
|
|
|
public function getBillingAddress() |
107
|
|
|
{ |
108
|
|
|
return $this->billingAddress; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* @param Address $billingAddress |
113
|
|
|
* |
114
|
|
|
* @return User |
115
|
|
|
*/ |
116
|
|
|
public function setBillingAddress(Address $billingAddress) |
117
|
|
|
{ |
118
|
|
|
$this->billingAddress = $billingAddress; |
119
|
|
|
|
120
|
|
|
return $this; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* @return string |
125
|
|
|
*/ |
126
|
|
|
public function getDateOfBirth() |
127
|
|
|
{ |
128
|
|
|
return $this->dateOfBirth; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* @param $dateOfBirth |
133
|
|
|
* |
134
|
|
|
* @return $this |
135
|
|
|
*/ |
136
|
|
|
public function setDateOfBirth($dateOfBirth) |
137
|
|
|
{ |
138
|
|
|
$this->dateOfBirth = $dateOfBirth; |
139
|
|
|
|
140
|
|
|
return $this; |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
/** |
144
|
|
|
* @return string |
145
|
|
|
*/ |
146
|
|
|
public function getDni() |
147
|
|
|
{ |
148
|
|
|
return $this->dni; |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* @param $dni |
153
|
|
|
* |
154
|
|
|
* @return $this |
155
|
|
|
*/ |
156
|
|
|
public function setDni($dni) |
157
|
|
|
{ |
158
|
|
|
$this->dni = $dni; |
159
|
|
|
|
160
|
|
|
return $this; |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
/** |
164
|
|
|
* @return string |
165
|
|
|
*/ |
166
|
|
|
public function getEmail() |
167
|
|
|
{ |
168
|
|
|
return $this->email; |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
/** |
172
|
|
|
* @param $email |
173
|
|
|
* |
174
|
|
|
* @return $this |
175
|
|
|
*/ |
176
|
|
|
public function setEmail($email) |
177
|
|
|
{ |
178
|
|
|
$this->email = $email; |
179
|
|
|
|
180
|
|
|
return $this; |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
/** |
184
|
|
|
* @return string |
185
|
|
|
*/ |
186
|
|
|
public function getFixPhone() |
187
|
|
|
{ |
188
|
|
|
return $this->fixPhone; |
189
|
|
|
} |
190
|
|
|
|
191
|
|
|
/** |
192
|
|
|
* @param string $fixPhone |
193
|
|
|
* |
194
|
|
|
* @return User |
195
|
|
|
*/ |
196
|
|
|
public function setFixPhone($fixPhone) |
197
|
|
|
{ |
198
|
|
|
$this->fixPhone = $fixPhone; |
199
|
|
|
|
200
|
|
|
return $this; |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
/** |
204
|
|
|
* @return string |
205
|
|
|
*/ |
206
|
|
|
public function getFullName() |
207
|
|
|
{ |
208
|
|
|
return $this->fullName; |
209
|
|
|
} |
210
|
|
|
|
211
|
|
|
/** |
212
|
|
|
* @param $fullName |
213
|
|
|
* |
214
|
|
|
* @return $this |
215
|
|
|
*/ |
216
|
|
|
public function setFullName($fullName) |
217
|
|
|
{ |
218
|
|
|
$this->fullName = $fullName; |
219
|
|
|
|
220
|
|
|
return $this; |
221
|
|
|
} |
222
|
|
|
|
223
|
|
|
/** |
224
|
|
|
* @return string |
225
|
|
|
*/ |
226
|
|
|
public function getMobilePhone() |
227
|
|
|
{ |
228
|
|
|
return $this->mobilePhone; |
229
|
|
|
} |
230
|
|
|
|
231
|
|
|
/** |
232
|
|
|
* @param string $mobilePhone |
233
|
|
|
* |
234
|
|
|
* @return User |
235
|
|
|
*/ |
236
|
|
|
public function setMobilePhone($mobilePhone) |
237
|
|
|
{ |
238
|
|
|
$this->mobilePhone = $mobilePhone; |
239
|
|
|
|
240
|
|
|
return $this; |
241
|
|
|
} |
242
|
|
|
|
243
|
|
|
/** |
244
|
|
|
* @return array |
245
|
|
|
*/ |
246
|
|
|
public function getOrderHistory() |
247
|
|
|
{ |
248
|
|
|
return $this->orderHistory; |
249
|
|
|
} |
250
|
|
|
|
251
|
|
|
/** |
252
|
|
|
* @param OrderHistory $orderHistory |
253
|
|
|
* |
254
|
|
|
* @return $this |
255
|
|
|
*/ |
256
|
|
|
public function addOrderHistory(OrderHistory $orderHistory) |
257
|
|
|
{ |
258
|
|
|
$this->orderHistory[] = $orderHistory; |
259
|
|
|
|
260
|
|
|
return $this; |
261
|
|
|
} |
262
|
|
|
|
263
|
|
|
/** |
264
|
|
|
* @return Address |
265
|
|
|
*/ |
266
|
|
|
public function getShippingAddress() |
267
|
|
|
{ |
268
|
|
|
return $this->shippingAddress; |
269
|
|
|
} |
270
|
|
|
|
271
|
|
|
/** |
272
|
|
|
* @param Address $shippingAddress |
273
|
|
|
* |
274
|
|
|
* @return User |
275
|
|
|
*/ |
276
|
|
|
public function setShippingAddress(Address $shippingAddress) |
277
|
|
|
{ |
278
|
|
|
$this->shippingAddress = $shippingAddress; |
279
|
|
|
|
280
|
|
|
return $this; |
281
|
|
|
} |
282
|
|
|
|
283
|
|
|
/** |
284
|
|
|
* Overwrite import to fill ordersHistory correctly |
285
|
|
|
* |
286
|
|
|
* @param $object |
287
|
|
|
* |
288
|
|
|
*/ |
289
|
|
|
public function import($object) |
290
|
|
|
{ |
291
|
|
|
parent::import($object); |
292
|
|
|
$properties = get_object_vars($object); |
293
|
|
|
foreach ($properties as $key => $value) { |
294
|
|
|
if (is_array($value) && $key == 'order_history') { |
295
|
|
|
$this->orderHistory = array(); |
296
|
|
|
foreach ($value as $orderHistory) { |
297
|
|
|
$orderHistoryObject = new OrderHistory(); |
298
|
|
|
$orderHistoryObject->import($orderHistory); |
299
|
|
|
$this->addOrderHistory($orderHistoryObject); |
300
|
|
|
} |
301
|
|
|
} |
302
|
|
|
} |
303
|
|
|
} |
304
|
|
|
} |
305
|
|
|
|