1
|
|
|
<?php namespace Stevenmaguire\OAuth2\Client\Provider; |
2
|
|
|
|
3
|
|
|
use League\OAuth2\Client\Provider\ResourceOwnerInterface; |
4
|
|
|
|
5
|
|
|
class PaypalResourceOwner implements ResourceOwnerInterface |
6
|
|
|
{ |
7
|
|
|
/** |
8
|
|
|
* Raw response |
9
|
|
|
* |
10
|
|
|
* @var array |
11
|
|
|
*/ |
12
|
|
|
protected $response; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Creates new resource owner. |
16
|
|
|
* |
17
|
|
|
* @param array $response |
18
|
|
|
*/ |
19
|
2 |
|
public function __construct(array $response = array()) |
20
|
|
|
{ |
21
|
2 |
|
$this->response = $response; |
22
|
2 |
|
} |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Get user id |
26
|
|
|
* |
27
|
|
|
* @return string|null |
28
|
|
|
*/ |
29
|
2 |
|
public function getId() |
30
|
|
|
{ |
31
|
2 |
|
return $this->response['user_id'] ?: null; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Get user name |
36
|
|
|
* |
37
|
|
|
* @return string|null |
38
|
|
|
*/ |
39
|
2 |
|
public function getName() |
40
|
|
|
{ |
41
|
2 |
|
return $this->response['name'] ?: null; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Get user given name |
46
|
|
|
* |
47
|
|
|
* @return string|null |
48
|
|
|
*/ |
49
|
2 |
|
public function getGivenName() |
50
|
|
|
{ |
51
|
2 |
|
return $this->response['given_name'] ?: null; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Get user family name |
56
|
|
|
* |
57
|
|
|
* @return string|null |
58
|
|
|
*/ |
59
|
2 |
|
public function getFamilyName() |
60
|
|
|
{ |
61
|
2 |
|
return $this->response['family_name'] ?: null; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Get user email |
66
|
|
|
* |
67
|
|
|
* @return string|null |
68
|
|
|
*/ |
69
|
2 |
|
public function getEmail() |
70
|
|
|
{ |
71
|
2 |
|
return $this->response['email'] ?: null; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Checks if user is verified |
76
|
|
|
* |
77
|
|
|
* @return boolean |
78
|
|
|
*/ |
79
|
2 |
|
public function isVerified() |
80
|
|
|
{ |
81
|
2 |
|
return $this->response['verified'] ?: false; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Get user gender |
86
|
|
|
* |
87
|
|
|
* @return string|null |
88
|
|
|
*/ |
89
|
2 |
|
public function getGender() |
90
|
|
|
{ |
91
|
2 |
|
return $this->response['gender'] ?: null; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* Get user birthdate |
96
|
|
|
* |
97
|
|
|
* @return string|null |
98
|
|
|
*/ |
99
|
2 |
|
public function getBirthdate() |
100
|
|
|
{ |
101
|
2 |
|
return $this->response['birthdate'] ?: null; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* Get user zoneinfo |
106
|
|
|
* |
107
|
|
|
* @return string|null |
108
|
|
|
*/ |
109
|
2 |
|
public function getZoneinfo() |
110
|
|
|
{ |
111
|
2 |
|
return $this->response['zoneinfo'] ?: null; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* Get user locale |
116
|
|
|
* |
117
|
|
|
* @return string|null |
118
|
|
|
*/ |
119
|
2 |
|
public function getLocale() |
120
|
|
|
{ |
121
|
2 |
|
return $this->response['locale'] ?: null; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* Get user phone number |
126
|
|
|
* |
127
|
|
|
* @return string|null |
128
|
|
|
*/ |
129
|
2 |
|
public function getPhoneNumber() |
130
|
|
|
{ |
131
|
2 |
|
return $this->response['phone_number'] ?: null; |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* Get user address |
136
|
|
|
* |
137
|
|
|
* @return array |
138
|
|
|
*/ |
139
|
2 |
|
public function getAddress() |
140
|
|
|
{ |
141
|
2 |
|
return $this->response['address'] ?: []; |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* Checks if user has verified account |
146
|
|
|
* |
147
|
|
|
* @return boolean |
148
|
|
|
*/ |
149
|
2 |
|
public function isVerifiedAccount() |
150
|
|
|
{ |
151
|
2 |
|
return $this->response['verified_account'] ?: false; |
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
/** |
155
|
|
|
* Get user account type |
156
|
|
|
* |
157
|
|
|
* @return string|null |
158
|
|
|
*/ |
159
|
2 |
|
public function getAccountType() |
160
|
|
|
{ |
161
|
2 |
|
return $this->response['account_type'] ?: null; |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
/** |
165
|
|
|
* Get user age range |
166
|
|
|
* |
167
|
|
|
* @return string|null |
168
|
|
|
*/ |
169
|
2 |
|
public function getAgeRange() |
170
|
|
|
{ |
171
|
2 |
|
return $this->response['age_range'] ?: null; |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* Get user payer id |
176
|
|
|
* |
177
|
|
|
* @return string|null |
178
|
|
|
*/ |
179
|
2 |
|
public function getPayerId() |
180
|
|
|
{ |
181
|
2 |
|
return $this->response['payer_id'] ?: null; |
182
|
|
|
} |
183
|
|
|
|
184
|
|
|
/** |
185
|
|
|
* Return all of the owner details available as an array. |
186
|
|
|
* |
187
|
|
|
* @return array |
188
|
|
|
*/ |
189
|
2 |
|
public function toArray() |
190
|
|
|
{ |
191
|
2 |
|
return $this->response; |
192
|
|
|
} |
193
|
|
|
} |
194
|
|
|
|