1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace PagaMasTarde\OrdersApiClient\Model\Order; |
4
|
|
|
|
5
|
|
|
use PagaMasTarde\OrdersApiClient\Model\AbstractModel; |
6
|
|
|
use PagaMasTarde\OrdersApiClient\Model\Order\User\Address; |
7
|
|
|
use PagaMasTarde\OrdersApiClient\Model\Order\User\OrderHistory; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Class User |
11
|
|
|
* @package PagaMasTarde\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
|
|
|
$dateOfBirthParsed = new \DateTime($dateOfBirth); |
139
|
|
|
$this->dateOfBirth = $dateOfBirthParsed->format('Y-m-d'); |
140
|
|
|
|
141
|
|
|
return $this; |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* @return string |
146
|
|
|
*/ |
147
|
|
|
public function getDni() |
148
|
|
|
{ |
149
|
|
|
return $this->dni; |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* @param $dni |
154
|
|
|
* |
155
|
|
|
* @return $this |
156
|
|
|
*/ |
157
|
|
|
public function setDni($dni) |
158
|
|
|
{ |
159
|
|
|
$this->dni = $dni; |
160
|
|
|
|
161
|
|
|
return $this; |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
/** |
165
|
|
|
* @return string |
166
|
|
|
*/ |
167
|
|
|
public function getEmail() |
168
|
|
|
{ |
169
|
|
|
return $this->email; |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
/** |
173
|
|
|
* @param $email |
174
|
|
|
* |
175
|
|
|
* @return $this |
176
|
|
|
*/ |
177
|
|
|
public function setEmail($email) |
178
|
|
|
{ |
179
|
|
|
$this->email = $email; |
180
|
|
|
|
181
|
|
|
return $this; |
182
|
|
|
} |
183
|
|
|
|
184
|
|
|
/** |
185
|
|
|
* @return string |
186
|
|
|
*/ |
187
|
|
|
public function getFixPhone() |
188
|
|
|
{ |
189
|
|
|
return $this->fixPhone; |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
/** |
193
|
|
|
* @param string $fixPhone |
194
|
|
|
* |
195
|
|
|
* @return User |
196
|
|
|
*/ |
197
|
|
|
public function setFixPhone($fixPhone) |
198
|
|
|
{ |
199
|
|
|
$this->fixPhone = $fixPhone; |
200
|
|
|
|
201
|
|
|
return $this; |
202
|
|
|
} |
203
|
|
|
|
204
|
|
|
/** |
205
|
|
|
* @return string |
206
|
|
|
*/ |
207
|
|
|
public function getFullName() |
208
|
|
|
{ |
209
|
|
|
return $this->fullName; |
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
/** |
213
|
|
|
* @param $fullName |
214
|
|
|
* |
215
|
|
|
* @return $this |
216
|
|
|
*/ |
217
|
|
|
public function setFullName($fullName) |
218
|
|
|
{ |
219
|
|
|
$this->fullName = $fullName; |
220
|
|
|
|
221
|
|
|
return $this; |
222
|
|
|
} |
223
|
|
|
|
224
|
|
|
/** |
225
|
|
|
* @return string |
226
|
|
|
*/ |
227
|
|
|
public function getMobilePhone() |
228
|
|
|
{ |
229
|
|
|
return $this->mobilePhone; |
230
|
|
|
} |
231
|
|
|
|
232
|
|
|
/** |
233
|
|
|
* @param string $mobilePhone |
234
|
|
|
* |
235
|
|
|
* @return User |
236
|
|
|
*/ |
237
|
|
|
public function setMobilePhone($mobilePhone) |
238
|
|
|
{ |
239
|
|
|
$this->mobilePhone = $mobilePhone; |
240
|
|
|
|
241
|
|
|
return $this; |
242
|
|
|
} |
243
|
|
|
|
244
|
|
|
/** |
245
|
|
|
* @return array |
246
|
|
|
*/ |
247
|
|
|
public function getOrderHistory() |
248
|
|
|
{ |
249
|
|
|
return $this->orderHistory; |
250
|
|
|
} |
251
|
|
|
|
252
|
|
|
/** |
253
|
|
|
* @param OrderHistory $orderHistory |
254
|
|
|
* |
255
|
|
|
* @return $this |
256
|
|
|
*/ |
257
|
|
|
public function addOrderHistory(OrderHistory $orderHistory) |
258
|
|
|
{ |
259
|
|
|
$this->orderHistory[] = $orderHistory; |
260
|
|
|
|
261
|
|
|
return $this; |
262
|
|
|
} |
263
|
|
|
|
264
|
|
|
/** |
265
|
|
|
* @return Address |
266
|
|
|
*/ |
267
|
|
|
public function getShippingAddress() |
268
|
|
|
{ |
269
|
|
|
return $this->shippingAddress; |
270
|
|
|
} |
271
|
|
|
|
272
|
|
|
/** |
273
|
|
|
* @param Address $shippingAddress |
274
|
|
|
* |
275
|
|
|
* @return User |
276
|
|
|
*/ |
277
|
|
|
public function setShippingAddress(Address $shippingAddress) |
278
|
|
|
{ |
279
|
|
|
$this->shippingAddress = $shippingAddress; |
280
|
|
|
|
281
|
|
|
return $this; |
282
|
|
|
} |
283
|
|
|
|
284
|
|
|
/** |
285
|
|
|
* Overwrite import to fill ordersHistory correctly |
286
|
|
|
* |
287
|
|
|
* @param $object |
288
|
|
|
* |
289
|
|
|
*/ |
290
|
|
|
public function import($object) |
291
|
|
|
{ |
292
|
|
|
parent::import($object); |
293
|
|
|
$properties = get_object_vars($object); |
294
|
|
|
foreach ($properties as $key => $value) { |
295
|
|
|
if (is_array($value) && $key == 'order_history') { |
296
|
|
|
$this->orderHistory = array(); |
297
|
|
|
foreach ($value as $orderHistory) { |
298
|
|
|
$orderHistoryObject = new OrderHistory(); |
299
|
|
|
$orderHistoryObject->import($orderHistory); |
300
|
|
|
$this->addOrderHistory($orderHistoryObject); |
301
|
|
|
} |
302
|
|
|
} |
303
|
|
|
} |
304
|
|
|
} |
305
|
|
|
} |
306
|
|
|
|