1 <?php
2 namespace PayPal\Api;
3
4 use PayPal\Common\PayPalResourceModel;
5 use PayPal\Rest\ApiContext;
6
7 /**
8 * Class OpenIdUserinfo
9 *
10 * OpenIdConnect UserInfo Resource
11 *
12 * @property string user_id
13 * @property string sub
14 * @property mixed name
15 * @property string given_name
16 * @property string family_name
17 * @property string middle_name
18 * @property string picture
19 * @property string email
20 * @property bool email_verified
21 * @property string gender
22 * @property string birthday
23 * @property string zoneinfo
24 * @property string locale
25 * @property string language
26 * @property bool verified
27 * @property string phone_number
28 * @property OpenIdAddress address
29 * @property mixed verified_account
30 * @property mixed account_type
31 * @property string age_range
32 * @property string payer_id
33 */
34 class OpenIdUserinfo extends PayPalResourceModel
35 {
36
37 /**
38 * Subject - Identifier for the End-User at the Issuer.
39 *
40 * @param string $user_id
41 * @return self
42 */
43 public function setUserId($user_id)
44 {
45 $this->user_id = $user_id;
46 return $this;
47 }
48
49 /**
50 * Subject - Identifier for the End-User at the Issuer.
51 *
52 * @return string
53 */
54 public function getUserId()
55 {
56 return $this->user_id;
57 }
58
59 /**
60 * Subject - Identifier for the End-User at the Issuer.
61 *
62 * @param string $sub
63 * @return self
64 */
65 public function setSub($sub)
66 {
67 $this->sub = $sub;
68 return $this;
69 }
70
71 /**
72 * Subject - Identifier for the End-User at the Issuer.
73 *
74 * @return string
75 */
76 public function getSub()
77 {
78 return $this->sub;
79 }
80
81 /**
82 * 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.
83 *
84 * @param string $name
85 * @return self
86 */
87 public function setName($name)
88 {
89 $this->name = $name;
90 return $this;
91 }
92
93 /**
94 * 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.
95 *
96 * @return string
97 */
98 public function getName()
99 {
100 return $this->name;
101 }
102
103 /**
104 * Given name(s) or first name(s) of the End-User
105 *
106 * @param string $given_name
107 * @return self
108 */
109 public function setGivenName($given_name)
110 {
111 $this->given_name = $given_name;
112 return $this;
113 }
114
115 /**
116 * Given name(s) or first name(s) of the End-User
117 *
118 * @return string
119 */
120 public function getGivenName()
121 {
122 return $this->given_name;
123 }
124
125 /**
126 * Surname(s) or last name(s) of the End-User.
127 *
128 * @param string $family_name
129 * @return self
130 */
131 public function setFamilyName($family_name)
132 {
133 $this->family_name = $family_name;
134 return $this;
135 }
136
137 /**
138 * Surname(s) or last name(s) of the End-User.
139 *
140 * @return string
141 */
142 public function getFamilyName()
143 {
144 return $this->family_name;
145 }
146
147 /**
148 * Middle name(s) of the End-User.
149 *
150 * @param string $middle_name
151 * @return self
152 */
153 public function setMiddleName($middle_name)
154 {
155 $this->middle_name = $middle_name;
156 return $this;
157 }
158
159 /**
160 * Middle name(s) of the End-User.
161 *
162 * @return string
163 */
164 public function getMiddleName()
165 {
166 return $this->middle_name;
167 }
168
169 /**
170 * URL of the End-User's profile picture.
171 *
172 * @param string $picture
173 * @return self
174 */
175 public function setPicture($picture)
176 {
177 $this->picture = $picture;
178 return $this;
179 }
180
181 /**
182 * URL of the End-User's profile picture.
183 *
184 * @return string
185 */
186 public function getPicture()
187 {
188 return $this->picture;
189 }
190
191 /**
192 * End-User's preferred e-mail address.
193 *
194 * @param string $email
195 * @return self
196 */
197 public function setEmail($email)
198 {
199 $this->email = $email;
200 return $this;
201 }
202
203 /**
204 * End-User's preferred e-mail address.
205 *
206 * @return string
207 */
208 public function getEmail()
209 {
210 return $this->email;
211 }
212
213 /**
214 * True if the End-User's e-mail address has been verified; otherwise false.
215 *
216 * @param boolean $email_verified
217 * @return self
218 */
219 public function setEmailVerified($email_verified)
220 {
221 $this->email_verified = $email_verified;
222 return $this;
223 }
224
225 /**
226 * True if the End-User's e-mail address has been verified; otherwise false.
227 *
228 * @return boolean
229 */
230 public function getEmailVerified()
231 {
232 return $this->email_verified;
233 }
234
235 /**
236 * End-User's gender.
237 *
238 * @param string $gender
239 * @return self
240 */
241 public function setGender($gender)
242 {
243 $this->gender = $gender;
244 return $this;
245 }
246
247 /**
248 * End-User's gender.
249 *
250 * @return string
251 */
252 public function getGender()
253 {
254 return $this->gender;
255 }
256
257 /**
258 * 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.
259 *
260 * @param string $birthday
261 * @return self
262 */
263 public function setBirthday($birthday)
264 {
265 $this->birthday = $birthday;
266 return $this;
267 }
268
269 /**
270 * 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.
271 *
272 * @return string
273 */
274 public function getBirthday()
275 {
276 return $this->birthday;
277 }
278
279 /**
280 * Time zone database representing the End-User's time zone
281 *
282 * @param string $zoneinfo
283 * @return self
284 */
285 public function setZoneinfo($zoneinfo)
286 {
287 $this->zoneinfo = $zoneinfo;
288 return $this;
289 }
290
291 /**
292 * Time zone database representing the End-User's time zone
293 *
294 * @return string
295 */
296 public function getZoneinfo()
297 {
298 return $this->zoneinfo;
299 }
300
301 /**
302 * End-User's locale.
303 *
304 * @param string $locale
305 * @return self
306 */
307 public function setLocale($locale)
308 {
309 $this->locale = $locale;
310 return $this;
311 }
312
313 /**
314 * End-User's locale.
315 *
316 * @return string
317 */
318 public function getLocale()
319 {
320 return $this->locale;
321 }
322
323 /**
324 * End-User's language.
325 *
326 * @param string $language
327 * @return self
328 */
329 public function setLanguage($language)
330 {
331 $this->language = $language;
332 return $this;
333 }
334
335 /**
336 * End-User's language.
337 *
338 * @return string
339 */
340 public function getLanguage()
341 {
342 return $this->language;
343 }
344
345 /**
346 * End-User's verified status.
347 *
348 * @param boolean $verified
349 * @return self
350 */
351 public function setVerified($verified)
352 {
353 $this->verified = $verified;
354 return $this;
355 }
356
357 /**
358 * End-User's verified status.
359 *
360 * @return boolean
361 */
362 public function getVerified()
363 {
364 return $this->verified;
365 }
366
367 /**
368 * End-User's preferred telephone number.
369 *
370 * @param string $phone_number
371 * @return self
372 */
373 public function setPhoneNumber($phone_number)
374 {
375 $this->phone_number = $phone_number;
376 return $this;
377 }
378
379 /**
380 * End-User's preferred telephone number.
381 *
382 * @return string
383 */
384 public function getPhoneNumber()
385 {
386 return $this->phone_number;
387 }
388
389 /**
390 * End-User's preferred address.
391 *
392 * @param \PayPal\Api\OpenIdAddress $address
393 * @return self
394 */
395 public function setAddress($address)
396 {
397 $this->address = $address;
398 return $this;
399 }
400
401 /**
402 * End-User's preferred address.
403 *
404 * @return \PayPal\Api\OpenIdAddress
405 */
406 public function getAddress()
407 {
408 return $this->address;
409 }
410
411 /**
412 * Verified account status.
413 *
414 * @param boolean $verified_account
415 * @return self
416 */
417 public function setVerifiedAccount($verified_account)
418 {
419 $this->verified_account = $verified_account;
420 return $this;
421 }
422
423 /**
424 * Verified account status.
425 *
426 * @return boolean
427 */
428 public function getVerifiedAccount()
429 {
430 return $this->verified_account;
431 }
432
433 /**
434 * Account type.
435 *
436 * @param string $account_type
437 * @return self
438 */
439 public function setAccountType($account_type)
440 {
441 $this->account_type = $account_type;
442 return $this;
443 }
444
445 /**
446 * Account type.
447 *
448 * @return string
449 */
450 public function getAccountType()
451 {
452 return $this->account_type;
453 }
454
455 /**
456 * Account holder age range.
457 *
458 * @param string $age_range
459 * @return self
460 */
461 public function setAgeRange($age_range)
462 {
463 $this->age_range = $age_range;
464 return $this;
465 }
466
467 /**
468 * Account holder age range.
469 *
470 * @return string
471 */
472 public function getAgeRange()
473 {
474 return $this->age_range;
475 }
476
477 /**
478 * Account payer identifier.
479 *
480 * @param string $payer_id
481 * @return self
482 */
483 public function setPayerId($payer_id)
484 {
485 $this->payer_id = $payer_id;
486 return $this;
487 }
488
489 /**
490 * Account payer identifier.
491 *
492 * @return string
493 */
494 public function getPayerId()
495 {
496 return $this->payer_id;
497 }
498
499
500 /**
501 * returns user details
502 *
503 * @path /v1/identity/openidconnect/userinfo
504 * @method GET
505 * @param array $params (allowed values are access_token)
506 * access_token - access token from the createFromAuthorizationCode / createFromRefreshToken calls
507 * @param ApiContext $apiContext Optional API Context
508 * @param PayPalRestCall $restCall
509 * @return OpenIdUserinfo
510 */
511 public static function getUserinfo($params, $apiContext = null, $restCall = null)
512 {
513 static $allowedParams = array('schema' => 1);
514
515 $params = is_array($params) ? $params : array();
516
517 if (!array_key_exists('schema', $params)) {
518 $params['schema'] = 'openid';
519 }
520 $requestUrl = "/v1/identity/openidconnect/userinfo?"
521 . http_build_query(array_intersect_key($params, $allowedParams));
522
523 $json = self::executeCall(
524 $requestUrl,
525 "GET",
526 "",
527 array(
528 'Authorization' => "Bearer " . $params['access_token'],
529 'Content-Type' => 'x-www-form-urlencoded'
530 ),
531 $apiContext,
532 $restCall
533 );
534
535 $ret = new OpenIdUserinfo();
536 $ret->fromJson($json);
537
538 return $ret;
539 }
540 }
541