1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Kerox\Messenger\Response; |
4
|
|
|
|
5
|
|
|
use Kerox\Messenger\Model\Referral; |
6
|
|
|
use Kerox\Messenger\UserInterface; |
7
|
|
|
use Psr\Http\Message\ResponseInterface; |
8
|
|
|
|
9
|
|
|
class UserResponse extends AbstractResponse implements UserInterface |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* @var null|string |
13
|
|
|
*/ |
14
|
|
|
protected $firstName; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @var null|string |
18
|
|
|
*/ |
19
|
|
|
protected $lastName; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @var null|string |
23
|
|
|
*/ |
24
|
|
|
protected $profilePic; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @var null|string |
28
|
|
|
*/ |
29
|
|
|
protected $locale; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var null|int |
33
|
|
|
*/ |
34
|
|
|
protected $timezone; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var null|string |
38
|
|
|
*/ |
39
|
|
|
protected $gender; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var null|bool |
43
|
|
|
*/ |
44
|
|
|
protected $paymentEnabled; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @var null|\Kerox\Messenger\Model\Referral |
48
|
|
|
*/ |
49
|
|
|
protected $lastAdReferral; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* UserProfileResponse constructor. |
53
|
|
|
* |
54
|
|
|
* @param \Psr\Http\Message\ResponseInterface $response |
55
|
|
|
*/ |
56
|
2 |
|
public function __construct(ResponseInterface $response) |
57
|
|
|
{ |
58
|
2 |
|
parent::__construct($response); |
59
|
2 |
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @param array $response |
63
|
|
|
*/ |
64
|
2 |
|
protected function parseResponse(array $response) |
65
|
|
|
{ |
66
|
2 |
|
$this->firstName = $response[self::FIRST_NAME] ?? null; |
67
|
2 |
|
$this->lastName = $response[self::LAST_NAME] ?? null; |
68
|
2 |
|
$this->profilePic = $response[self::PROFILE_PIC] ?? null; |
69
|
2 |
|
$this->profilePic = $response[self::PROFILE_PIC] ?? null; |
70
|
2 |
|
$this->locale = $response[self::LOCALE] ?? null; |
71
|
2 |
|
$this->timezone = $response[self::TIMEZONE] ?? null; |
72
|
2 |
|
$this->gender = $response[self::GENDER] ?? null; |
73
|
2 |
|
$this->paymentEnabled = $response[self::IS_PAYMENT_ENABLED] ?? null; |
74
|
|
|
|
75
|
2 |
|
$this->setLastAdReferral($response); |
76
|
2 |
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @return null|string |
80
|
|
|
*/ |
81
|
1 |
|
public function getFirstName() |
82
|
|
|
{ |
83
|
1 |
|
return $this->firstName; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @return null|string |
88
|
|
|
*/ |
89
|
1 |
|
public function getLastName() |
90
|
|
|
{ |
91
|
1 |
|
return $this->lastName; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @return null|string |
96
|
|
|
*/ |
97
|
1 |
|
public function getProfilePic() |
98
|
|
|
{ |
99
|
1 |
|
return $this->profilePic; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @return null|string |
104
|
|
|
*/ |
105
|
1 |
|
public function getLocale() |
106
|
|
|
{ |
107
|
1 |
|
return $this->locale; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* @return null|int |
112
|
|
|
*/ |
113
|
1 |
|
public function getTimezone() |
114
|
|
|
{ |
115
|
1 |
|
return $this->timezone; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* @return null|string |
120
|
|
|
*/ |
121
|
1 |
|
public function getGender() |
122
|
|
|
{ |
123
|
1 |
|
return $this->gender; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* @return null|bool |
128
|
|
|
*/ |
129
|
1 |
|
public function isPaymentEnabled() |
130
|
|
|
{ |
131
|
1 |
|
return $this->paymentEnabled; |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* @return null|\Kerox\Messenger\Model\Referral |
136
|
|
|
*/ |
137
|
1 |
|
public function getLastAdReferral() |
138
|
|
|
{ |
139
|
1 |
|
return $this->lastAdReferral; |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* @param array $response |
144
|
|
|
*/ |
145
|
2 |
|
private function setLastAdReferral(array $response) |
146
|
|
|
{ |
147
|
2 |
|
if (isset($response[self::LAST_AD_REFERRAL])) { |
148
|
2 |
|
$this->lastAdReferral = Referral::create($response[self::LAST_AD_REFERRAL]); |
149
|
|
|
} |
150
|
2 |
|
} |
151
|
|
|
} |
152
|
|
|
|