1
|
|
|
<?php |
2
|
|
|
namespace Wonnova\SDK\Model; |
3
|
|
|
|
4
|
|
|
use JMS\Serializer\Annotation as JMS; |
5
|
|
|
use Wonnova\SDK\Common\WonnovaDateTimeParserTrait; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Class User |
9
|
|
|
* @author Wonnova |
10
|
|
|
* @link http://www.wonnova.com |
11
|
|
|
*/ |
12
|
|
|
class User extends AbstractModel |
13
|
|
|
{ |
14
|
|
|
use WonnovaDateTimeParserTrait; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Used to map virtual to real fields |
18
|
|
|
* |
19
|
|
|
* @var array |
20
|
|
|
* @JMS\Exclude() |
21
|
|
|
*/ |
22
|
|
|
protected $fieldMapping = [ |
23
|
|
|
'points' => 'score' |
24
|
|
|
]; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @var string |
28
|
|
|
* @JMS\Type("string") |
29
|
|
|
*/ |
30
|
|
|
private $userId; |
31
|
|
|
/** |
32
|
|
|
* @var string |
33
|
|
|
* @JMS\Type("string") |
34
|
|
|
*/ |
35
|
|
|
private $username; |
36
|
|
|
/** |
37
|
|
|
* @var string |
38
|
|
|
* @JMS\Type("string") |
39
|
|
|
*/ |
40
|
|
|
private $provider; |
41
|
|
|
/** |
42
|
|
|
* @var string |
43
|
|
|
* @JMS\Type("string") |
44
|
|
|
*/ |
45
|
|
|
private $fullName; |
46
|
|
|
/** |
47
|
|
|
* @var string |
48
|
|
|
* @JMS\Type("string") |
49
|
|
|
*/ |
50
|
|
|
private $avatar; |
51
|
|
|
/** |
52
|
|
|
* @var \DateTime |
53
|
|
|
* @JMS\Type("WonnovaDateTime") |
54
|
|
|
*/ |
55
|
|
|
private $dateOfBirth; |
56
|
|
|
/** |
57
|
|
|
* @var string |
58
|
|
|
* @JMS\Type("string") |
59
|
|
|
*/ |
60
|
|
|
private $email; |
61
|
|
|
/** |
62
|
|
|
* @var string |
63
|
|
|
* @JMS\Type("string") |
64
|
|
|
*/ |
65
|
|
|
private $address; |
66
|
|
|
/** |
67
|
|
|
* @var string |
68
|
|
|
* @JMS\Type("string") |
69
|
|
|
*/ |
70
|
|
|
private $city; |
71
|
|
|
/** |
72
|
|
|
* @var string |
73
|
|
|
* @JMS\Type("string") |
74
|
|
|
*/ |
75
|
|
|
private $country; |
76
|
|
|
/** |
77
|
|
|
* @var string |
78
|
|
|
* @JMS\Type("string") |
79
|
|
|
*/ |
80
|
|
|
private $postalCode; |
81
|
|
|
/** |
82
|
|
|
* @var string |
83
|
|
|
* @JMS\Type("string") |
84
|
|
|
*/ |
85
|
|
|
private $phone; |
86
|
|
|
/** |
87
|
|
|
* @var string |
88
|
|
|
* @JMS\Type("string") |
89
|
|
|
*/ |
90
|
|
|
private $gender; |
91
|
|
|
/** |
92
|
|
|
* @var string |
93
|
|
|
* @JMS\Type("string") |
94
|
|
|
*/ |
95
|
|
|
private $locale; |
96
|
|
|
/** |
97
|
|
|
* @var string |
98
|
|
|
* @JMS\Type("string") |
99
|
|
|
*/ |
100
|
|
|
private $timezone; |
101
|
|
|
/** |
102
|
|
|
* @var integer |
103
|
|
|
* @JMS\Type("integer") |
104
|
|
|
* @JMS\SerializedName("points") |
105
|
|
|
*/ |
106
|
|
|
private $score; |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @return string |
110
|
|
|
*/ |
111
|
7 |
|
public function getUserId() |
112
|
|
|
{ |
113
|
7 |
|
return $this->userId; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* @param string $userId |
118
|
|
|
* @return $this |
119
|
|
|
*/ |
120
|
4 |
|
public function setUserId($userId) |
121
|
|
|
{ |
122
|
4 |
|
$this->userId = $userId; |
123
|
4 |
|
return $this; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* @return string |
128
|
|
|
*/ |
129
|
5 |
|
public function getUsername() |
130
|
|
|
{ |
131
|
5 |
|
return $this->username; |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* @param string $username |
136
|
|
|
* @return $this |
137
|
|
|
*/ |
138
|
3 |
|
public function setUsername($username) |
139
|
|
|
{ |
140
|
3 |
|
$this->username = $username; |
141
|
3 |
|
return $this; |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* @return string |
146
|
|
|
*/ |
147
|
4 |
|
public function getProvider() |
148
|
|
|
{ |
149
|
4 |
|
return $this->provider; |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* @param string $provider |
154
|
|
|
* @return $this |
155
|
|
|
*/ |
156
|
2 |
|
public function setProvider($provider) |
157
|
|
|
{ |
158
|
2 |
|
$this->provider = $provider; |
159
|
2 |
|
return $this; |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
/** |
163
|
|
|
* @return string |
164
|
|
|
*/ |
165
|
2 |
|
public function getFullName() |
166
|
|
|
{ |
167
|
2 |
|
return $this->fullName; |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
/** |
171
|
|
|
* @param string $fullName |
172
|
|
|
* @return $this |
173
|
|
|
*/ |
174
|
4 |
|
public function setFullName($fullName) |
175
|
|
|
{ |
176
|
4 |
|
$this->fullName = $fullName; |
177
|
4 |
|
return $this; |
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
/** |
181
|
|
|
* @return string |
182
|
|
|
*/ |
183
|
2 |
|
public function getAvatar() |
184
|
|
|
{ |
185
|
2 |
|
return $this->avatar; |
186
|
|
|
} |
187
|
|
|
|
188
|
|
|
/** |
189
|
|
|
* @param string $avatar |
190
|
|
|
* @return $this |
191
|
|
|
*/ |
192
|
3 |
|
public function setAvatar($avatar) |
193
|
|
|
{ |
194
|
3 |
|
$this->avatar = $avatar; |
195
|
3 |
|
return $this; |
196
|
|
|
} |
197
|
|
|
|
198
|
|
|
/** |
199
|
|
|
* @return \DateTime |
200
|
|
|
*/ |
201
|
5 |
|
public function getDateOfBirth() |
202
|
|
|
{ |
203
|
5 |
|
return $this->dateOfBirth; |
204
|
|
|
} |
205
|
|
|
|
206
|
|
|
/** |
207
|
|
|
* @param \DateTime|array|string $dateOfBirth |
208
|
|
|
* @return $this |
209
|
|
|
*/ |
210
|
4 |
|
public function setDateOfBirth($dateOfBirth) |
211
|
|
|
{ |
212
|
4 |
|
$this->dateOfBirth = $this->parseWonnovaDateTime($dateOfBirth); |
213
|
4 |
|
return $this; |
214
|
|
|
} |
215
|
|
|
|
216
|
|
|
/** |
217
|
|
|
* @return string |
218
|
|
|
*/ |
219
|
1 |
|
public function getEmail() |
220
|
|
|
{ |
221
|
1 |
|
return $this->email; |
222
|
|
|
} |
223
|
|
|
|
224
|
|
|
/** |
225
|
|
|
* @param string $email |
226
|
|
|
* @return $this |
227
|
|
|
*/ |
228
|
3 |
|
public function setEmail($email) |
229
|
|
|
{ |
230
|
3 |
|
$this->email = $email; |
231
|
3 |
|
return $this; |
232
|
|
|
} |
233
|
|
|
|
234
|
|
|
/** |
235
|
|
|
* @return string |
236
|
|
|
*/ |
237
|
1 |
|
public function getAddress() |
238
|
|
|
{ |
239
|
1 |
|
return $this->address; |
240
|
|
|
} |
241
|
|
|
|
242
|
|
|
/** |
243
|
|
|
* @param string $address |
244
|
|
|
* @return $this |
245
|
|
|
*/ |
246
|
2 |
|
public function setAddress($address) |
247
|
|
|
{ |
248
|
2 |
|
$this->address = $address; |
249
|
2 |
|
return $this; |
250
|
|
|
} |
251
|
|
|
|
252
|
|
|
/** |
253
|
|
|
* @return string |
254
|
|
|
*/ |
255
|
1 |
|
public function getCity() |
256
|
|
|
{ |
257
|
1 |
|
return $this->city; |
258
|
|
|
} |
259
|
|
|
|
260
|
|
|
/** |
261
|
|
|
* @param string $city |
262
|
|
|
* @return $this |
263
|
|
|
*/ |
264
|
2 |
|
public function setCity($city) |
265
|
|
|
{ |
266
|
2 |
|
$this->city = $city; |
267
|
2 |
|
return $this; |
268
|
|
|
} |
269
|
|
|
|
270
|
|
|
/** |
271
|
|
|
* @return string |
272
|
|
|
*/ |
273
|
1 |
|
public function getCountry() |
274
|
|
|
{ |
275
|
1 |
|
return $this->country; |
276
|
|
|
} |
277
|
|
|
|
278
|
|
|
/** |
279
|
|
|
* @param string $country |
280
|
|
|
* @return $this |
281
|
|
|
*/ |
282
|
2 |
|
public function setCountry($country) |
283
|
|
|
{ |
284
|
2 |
|
$this->country = $country; |
285
|
2 |
|
return $this; |
286
|
|
|
} |
287
|
|
|
|
288
|
|
|
/** |
289
|
|
|
* @return string |
290
|
|
|
*/ |
291
|
1 |
|
public function getPostalCode() |
292
|
|
|
{ |
293
|
1 |
|
return $this->postalCode; |
294
|
|
|
} |
295
|
|
|
|
296
|
|
|
/** |
297
|
|
|
* @param string $postalCode |
298
|
|
|
* @return $this |
299
|
|
|
*/ |
300
|
2 |
|
public function setPostalCode($postalCode) |
301
|
|
|
{ |
302
|
2 |
|
$this->postalCode = $postalCode; |
303
|
2 |
|
return $this; |
304
|
|
|
} |
305
|
|
|
|
306
|
|
|
/** |
307
|
|
|
* @return string |
308
|
|
|
*/ |
309
|
1 |
|
public function getPhone() |
310
|
|
|
{ |
311
|
1 |
|
return $this->phone; |
312
|
|
|
} |
313
|
|
|
|
314
|
|
|
/** |
315
|
|
|
* @param string $phone |
316
|
|
|
* @return $this |
317
|
|
|
*/ |
318
|
2 |
|
public function setPhone($phone) |
319
|
|
|
{ |
320
|
2 |
|
$this->phone = $phone; |
321
|
2 |
|
return $this; |
322
|
|
|
} |
323
|
|
|
|
324
|
|
|
/** |
325
|
|
|
* @return string |
326
|
|
|
*/ |
327
|
1 |
|
public function getGender() |
328
|
|
|
{ |
329
|
1 |
|
return $this->gender; |
330
|
|
|
} |
331
|
|
|
|
332
|
|
|
/** |
333
|
|
|
* @param string $gender |
334
|
|
|
* @return $this |
335
|
|
|
*/ |
336
|
2 |
|
public function setGender($gender) |
337
|
|
|
{ |
338
|
2 |
|
$this->gender = $gender; |
339
|
2 |
|
return $this; |
340
|
|
|
} |
341
|
|
|
|
342
|
|
|
/** |
343
|
|
|
* @return string |
344
|
|
|
*/ |
345
|
1 |
|
public function getLocale() |
346
|
|
|
{ |
347
|
1 |
|
return $this->locale; |
348
|
|
|
} |
349
|
|
|
|
350
|
|
|
/** |
351
|
|
|
* @param string $locale |
352
|
|
|
* @return $this |
353
|
|
|
*/ |
354
|
2 |
|
public function setLocale($locale) |
355
|
|
|
{ |
356
|
2 |
|
$this->locale = $locale; |
357
|
2 |
|
return $this; |
358
|
|
|
} |
359
|
|
|
|
360
|
|
|
/** |
361
|
|
|
* @return string |
362
|
|
|
*/ |
363
|
3 |
|
public function getTimezone() |
364
|
|
|
{ |
365
|
3 |
|
return $this->timezone; |
366
|
|
|
} |
367
|
|
|
|
368
|
|
|
/** |
369
|
|
|
* @param string $timezone |
370
|
|
|
* @return $this |
371
|
|
|
*/ |
372
|
2 |
|
public function setTimezone($timezone) |
373
|
|
|
{ |
374
|
2 |
|
$this->timezone = $timezone; |
375
|
2 |
|
return $this; |
376
|
|
|
} |
377
|
|
|
|
378
|
|
|
/** |
379
|
|
|
* @return integer |
380
|
|
|
*/ |
381
|
1 |
|
public function getScore() |
382
|
|
|
{ |
383
|
1 |
|
return $this->score; |
384
|
|
|
} |
385
|
|
|
|
386
|
|
|
/** |
387
|
|
|
* @param integer $score |
388
|
|
|
* @return $this |
389
|
|
|
*/ |
390
|
1 |
|
public function setScore($score) |
391
|
|
|
{ |
392
|
1 |
|
$this->score = $score; |
393
|
1 |
|
return $this; |
394
|
|
|
} |
395
|
|
|
|
396
|
|
|
/** |
397
|
|
|
* Returns a copy data array of this object |
398
|
|
|
* |
399
|
|
|
* @return array |
400
|
|
|
*/ |
401
|
2 |
|
public function toArray() |
402
|
|
|
{ |
403
|
|
|
return [ |
404
|
2 |
|
'userId' => $this->userId, |
405
|
2 |
|
'username' => $this->username, |
406
|
2 |
|
'provider' => $this->provider, |
407
|
2 |
|
'fullName' => $this->fullName, |
408
|
2 |
|
'avatar' => $this->avatar, |
409
|
2 |
|
'dateOfBirth' => $this->dateOfBirth instanceof \DateTime |
410
|
2 |
|
? $this->dateOfBirth->format('Y-m-d H:i:s') |
411
|
2 |
|
: $this->dateOfBirth, |
412
|
2 |
|
'email' => $this->email, |
413
|
2 |
|
'address' => $this->address, |
414
|
2 |
|
'city' => $this->city, |
415
|
2 |
|
'country' => $this->country, |
416
|
2 |
|
'postalCode' => $this->postalCode, |
417
|
2 |
|
'phone' => $this->phone, |
418
|
2 |
|
'gender' => $this->gender, |
419
|
2 |
|
'locale' => $this->locale, |
420
|
2 |
|
'timezone' => $this->timezone, |
421
|
2 |
|
'score' => $this->score |
422
|
2 |
|
]; |
423
|
|
|
} |
424
|
|
|
} |
425
|
|
|
|