|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Srmklive\PayPal\Traits\PayPalAPI; |
|
4
|
|
|
|
|
5
|
|
|
trait Identity |
|
6
|
|
|
{ |
|
7
|
|
|
/** |
|
8
|
|
|
* Get user profile information. |
|
9
|
|
|
* |
|
10
|
|
|
* @throws \Throwable |
|
11
|
|
|
* |
|
12
|
|
|
* @return array|\Psr\Http\Message\StreamInterface|string |
|
13
|
|
|
* |
|
14
|
|
|
* @see https://developer.paypal.com/docs/api/identity/v1/#userinfo_get |
|
15
|
|
|
*/ |
|
16
|
|
|
public function showProfileInfo() |
|
17
|
|
|
{ |
|
18
|
|
|
$this->apiEndPoint = 'v1/identity/openidconnect/userinfo?schema=openid'; |
|
19
|
|
|
|
|
20
|
|
|
$this->setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); |
|
|
|
|
|
|
21
|
|
|
|
|
22
|
|
|
$this->verb = 'get'; |
|
23
|
|
|
|
|
24
|
|
|
return $this->doPayPalRequest(); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* List Users. |
|
29
|
|
|
* |
|
30
|
|
|
* @param string $field |
|
31
|
|
|
* |
|
32
|
|
|
* @throws \Throwable |
|
33
|
|
|
* |
|
34
|
|
|
* @return array|\Psr\Http\Message\StreamInterface|string |
|
35
|
|
|
* |
|
36
|
|
|
* @see https://developer.paypal.com/docs/api/identity/v2/#users_list |
|
37
|
|
|
*/ |
|
38
|
|
|
public function listUsers(string $field = 'userName') |
|
39
|
|
|
{ |
|
40
|
|
|
$this->apiEndPoint = "v2/scim/Users?filter={$field}"; |
|
41
|
|
|
|
|
42
|
|
|
$this->setRequestHeader('Content-Type', 'application/scim+json'); |
|
43
|
|
|
|
|
44
|
|
|
$this->verb = 'get'; |
|
45
|
|
|
|
|
46
|
|
|
return $this->doPayPalRequest(); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* Show details for a user by ID. |
|
51
|
|
|
* |
|
52
|
|
|
* @param string $user_id |
|
53
|
|
|
* |
|
54
|
|
|
* @throws \Throwable |
|
55
|
|
|
* |
|
56
|
|
|
* @return array|\Psr\Http\Message\StreamInterface|string |
|
57
|
|
|
* |
|
58
|
|
|
* @see https://developer.paypal.com/docs/api/identity/v2/#users_get |
|
59
|
|
|
*/ |
|
60
|
|
|
public function showUserDetails(string $user_id) |
|
61
|
|
|
{ |
|
62
|
|
|
$this->apiEndPoint = "v2/scim/Users/{$user_id}"; |
|
63
|
|
|
|
|
64
|
|
|
$this->setRequestHeader('Content-Type', 'application/scim+json'); |
|
65
|
|
|
|
|
66
|
|
|
$this->verb = 'get'; |
|
67
|
|
|
|
|
68
|
|
|
return $this->doPayPalRequest(); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Delete a user by ID. |
|
73
|
|
|
* |
|
74
|
|
|
* @param string $user_id |
|
75
|
|
|
* |
|
76
|
|
|
* @throws \Throwable |
|
77
|
|
|
* |
|
78
|
|
|
* @return array|\Psr\Http\Message\StreamInterface|string |
|
79
|
|
|
* |
|
80
|
|
|
* @see https://developer.paypal.com/docs/api/identity/v2/#users_get |
|
81
|
|
|
*/ |
|
82
|
|
|
public function deleteUser(string $user_id) |
|
83
|
|
|
{ |
|
84
|
|
|
$this->apiEndPoint = "v2/scim/Users/{$user_id}"; |
|
85
|
|
|
|
|
86
|
|
|
$this->setRequestHeader('Content-Type', 'application/scim+json'); |
|
87
|
|
|
|
|
88
|
|
|
$this->verb = 'delete'; |
|
89
|
|
|
|
|
90
|
|
|
return $this->doPayPalRequest(false); |
|
91
|
|
|
} |
|
92
|
|
|
} |
|
93
|
|
|
|