29ff51f4094611b24a084d84f24f10dc93846d0e
[WP-Plugins/glm-member-db.git] /
1 <?php
2 namespace PayPal\Auth\Openid;
3 use PayPal\Common\PPModel;
4 /**
5  * OpenIdConnect UserInfo Resource
6  */
7 class PPOpenIdUserinfo extends PPModel {
8
9                 /**
10                  * Subject - Identifier for the End-User at the Issuer.
11                  * @param string $user_id
12                  */
13                  public function setUserId($user_id) {
14                         $this->user_id = $user_id;
15                         return $this;
16                  }
17                 
18                 /**
19                  * Subject - Identifier for the End-User at the Issuer.
20                  * @return string
21                  */
22                  public function getUserId() {
23                         return $this->user_id;
24                  }
25                  
26                 /**
27                  * Subject - Identifier for the End-User at the Issuer.
28                  * @param string $sub
29                  */
30                  public function setSub($sub) {
31                         $this->sub = $sub;
32                         return $this;
33                  }
34                 
35                 /**
36                  * Subject - Identifier for the End-User at the Issuer.
37                  * @return string
38                  */
39                  public function getSub() {
40                         return $this->sub;
41                  }
42                  
43                 /**
44                  * End-User's full name in displayable form including all name parts, possibly including titles and suffixes, ordered according to the End-User's locale and preferences.
45                  * @param string $name
46                  */
47                  public function setName($name) {
48                         $this->name = $name;
49                         return $this;
50                  }
51                 
52                 /**
53                  * End-User's full name in displayable form including all name parts, possibly including titles and suffixes, ordered according to the End-User's locale and preferences.
54                  * @return string
55                  */
56                  public function getName() {
57                         return $this->name;
58                  }
59                  
60                 /**
61                  * Given name(s) or first name(s) of the End-User
62                  * @param string $given_name
63                  */
64                  public function setGivenName($given_name) {
65                         $this->given_name = $given_name;
66                         return $this;
67                  }
68                 
69                 /**
70                  * Given name(s) or first name(s) of the End-User
71                  * @return string
72                  */
73                  public function getGivenName() {
74                         return $this->given_name;
75                  }
76                  
77                 /**
78                  * Surname(s) or last name(s) of the End-User.
79                  * @param string $family_name
80                  */
81                  public function setFamilyName($family_name) {
82                         $this->family_name = $family_name;
83                         return $this;
84                  }
85                 
86                 /**
87                  * Surname(s) or last name(s) of the End-User.
88                  * @return string
89                  */
90                  public function getFamilyName() {
91                         return $this->family_name;
92                  }
93                  
94                 /**
95                  * Middle name(s) of the End-User.
96                  * @param string $middle_name
97                  */
98                  public function setMiddleName($middle_name) {
99                         $this->middle_name = $middle_name;
100                         return $this;
101                  }
102                 
103                 /**
104                  * Middle name(s) of the End-User.
105                  * @return string
106                  */
107                  public function getMiddleName() {
108                         return $this->middle_name;
109                  }
110                  
111                 /**
112                  * URL of the End-User's profile picture.
113                  * @param string $picture
114                  */
115                  public function setPicture($picture) {
116                         $this->picture = $picture;
117                         return $this;
118                  }
119                 
120                 /**
121                  * URL of the End-User's profile picture.
122                  * @return string
123                  */
124                  public function getPicture() {
125                         return $this->picture;
126                  }
127                  
128                 /**
129                  * End-User's preferred e-mail address.
130                  * @param string $email
131                  */
132                  public function setEmail($email) {
133                         $this->email = $email;
134                         return $this;
135                  }
136                 
137                 /**
138                  * End-User's preferred e-mail address.
139                  * @return string
140                  */
141                  public function getEmail() {
142                         return $this->email;
143                  }
144                  
145                 /**
146                  * True if the End-User's e-mail address has been verified; otherwise false.
147                  * @param boolean $email_verified
148                  */
149                  public function setEmailVerified($email_verified) {
150                         $this->email_verified = $email_verified;
151                         return $this;
152                  }
153                 
154                 /**
155                  * True if the End-User's e-mail address has been verified; otherwise false.
156                  * @return boolean
157                  */
158                  public function getEmailVerified() {
159                         return $this->email_verified;
160                  }
161                  
162                 /**
163                  * End-User's gender.
164                  * @param string $gender
165                  */
166                  public function setGender($gender) {
167                         $this->gender = $gender;
168                         return $this;
169                  }
170                 
171                 /**
172                  * End-User's gender.
173                  * @return string
174                  */
175                  public function getGender() {
176                         return $this->gender;
177                  }
178                  
179                 /**
180                  * End-User's birthday, represented as an YYYY-MM-DD format. They year MAY be 0000, indicating it is omited. To represent only the year, YYYY format would be used.
181                  * @param string $birthday
182                  */
183                  public function setBirthday($birthday) {
184                         $this->birthday = $birthday;
185                         return $this;
186                  }
187                 
188                 /**
189                  * End-User's birthday, represented as an YYYY-MM-DD format. They year MAY be 0000, indicating it is omited. To represent only the year, YYYY format would be used.
190                  * @return string
191                  */
192                  public function getBirthday() {
193                         return $this->birthday;
194                  }
195                  
196                 /**
197                  * Time zone database representing the End-User's time zone
198                  * @param string $zoneinfo
199                  */
200                  public function setZoneinfo($zoneinfo) {
201                         $this->zoneinfo = $zoneinfo;
202                         return $this;
203                  }
204                 
205                 /**
206                  * Time zone database representing the End-User's time zone
207                  * @return string
208                  */
209                  public function getZoneinfo() {
210                         return $this->zoneinfo;
211                  }
212                  
213                 /**
214                  * End-User's locale.
215                  * @param string $locale
216                  */
217                  public function setLocale($locale) {
218                         $this->locale = $locale;
219                         return $this;
220                  }
221                 
222                 /**
223                  * End-User's locale.
224                  * @return string
225                  */
226                  public function getLocale() {
227                         return $this->locale;
228                  }
229                  
230                 /**
231                  * End-User's language.
232                  * @param string $language
233                  */
234                  public function setLanguage($language) {
235                         $this->language = $language;
236                         return $this;
237                  }
238                 
239                 /**
240                  * End-User's language.
241                  * @return string
242                  */
243                  public function getLanguage() {
244                         return $this->language;
245                  }
246                  
247                 /**
248                  * End-User's verified status.
249                  * @param boolean $verified
250                  */
251                  public function setVerified($verified) {
252                         $this->verified = $verified;
253                         return $this;
254                  }
255                 
256                 /**
257                  * End-User's verified status.
258                  * @return boolean
259                  */
260                  public function getVerified() {
261                         return $this->verified;
262                  }
263                  
264                 /**
265                  * End-User's preferred telephone number.
266                  * @param string $phone_number
267                  */
268                  public function setPhoneNumber($phone_number) {
269                         $this->phone_number = $phone_number;
270                         return $this;
271                  }
272                 
273                 /**
274                  * End-User's preferred telephone number.
275                  * @return string
276                  */
277                  public function getPhoneNumber() {
278                         return $this->phone_number;
279                  }
280                  
281                 /**
282                  * End-User's preferred address.
283                  * @param PPOpenIdAddress $address
284                  */
285                  public function setAddress($address) {
286                         $this->address = $address;
287                         return $this;
288                  }
289                 
290                 /**
291                  * End-User's preferred address.
292                  * @return PPOpenIdAddress
293                  */
294                  public function getAddress() {
295                         return $this->address;
296                  }
297                  
298                 /**
299                  * Verified account status.
300                  * @param boolean $verified_account
301                  */
302                  public function setVerifiedAccount($verified_account) {
303                         $this->verified_account = $verified_account;
304                         return $this;
305                  }
306                 
307                 /**
308                  * Verified account status.
309                  * @return boolean
310                  */
311                  public function getVerifiedAccount() {
312                         return $this->verified_account;
313                  }
314                  
315                 /**
316                  * Account type.
317                  * @param string $account_type
318                  */
319                  public function setAccountType($account_type) {
320                         $this->account_type = $account_type;
321                         return $this;
322                  }
323                 
324                 /**
325                  * Account type.
326                  * @return string
327                  */
328                  public function getAccountType() {
329                         return $this->account_type;
330                  }
331                  
332                 /**
333                  * Account holder age range.
334                  * @param string $age_range
335                  */
336                  public function setAgeRange($age_range) {
337                         $this->age_range = $age_range;
338                         return $this;
339                  }
340                 
341                 /**
342                  * Account holder age range.
343                  * @return string
344                  */
345                  public function getAgeRange() {
346                         return $this->age_range;
347                  }
348                  
349                 /**
350                  * Account payer identifier.
351                  * @param string $payer_id
352                  */
353                  public function setPayerId($payer_id) {
354                         $this->payer_id = $payer_id;
355                         return $this;
356                  }
357                 
358                 /**
359                  * Account payer identifier.
360                  * @return string
361                  */
362                  public function getPayerId() {
363                         return $this->payer_id;
364                  }
365                  
366
367         /**
368                  * returns user details
369                  *
370                  * @path /v1/identity/openidconnect/userinfo
371                  * @method GET
372                  * @param array $params (allowed values are access_token)
373                  *                                      access_token - access token from the createFromAuthorizationCode / createFromRefreshToken calls  
374                  * @param PPApiContext $apiContext Optional API Context
375                  * @return PPOpenIdUserinfo
376                  */
377                 public static function getUserinfo($params, $apiContext=null) {
378                         static $allowedParams = array( 'schema' => 1);
379                         if(is_null($apiContext)) {
380                                 $apiContext = new PPApiContext();
381                         }
382                                                 
383                         if(!array_key_exists('schema', $params)) {
384                                 $params['schema'] = 'openid';
385                         }                       
386                         $requestUrl = "/v1/identity/openidconnect/userinfo?"
387                                         . http_build_query(array_intersect_key($params, $allowedParams));                       
388                         $call = new PPRestCall($apiContext);
389                         $ret = new PPOpenIdUserinfo();
390                         $ret->fromJson(
391                                 $call->execute(array('PPOpenIdHandler'), $requestUrl, "GET", "", 
392                                         array(
393                                                 'Authorization' => "Bearer " . $params['access_token'],
394                                                 'Content-Type'=> 'x-www-form-urlencoded'
395                                         )
396                                 )
397                         );
398                         return $ret;
399                 }
400 }