-
Notifications
You must be signed in to change notification settings - Fork 116
Expand file tree
/
Copy pathProfile.php
More file actions
157 lines (145 loc) · 4.19 KB
/
Profile.php
File metadata and controls
157 lines (145 loc) · 4.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<?php
/**
* User hosting
*/
namespace RongCloud\Lib\User\Profile;
use RongCloud\Lib\Request;
use RongCloud\Lib\Utils;
class Profile
{
/**
* User Entrustment
*
* @var string
*/
private $jsonPath = 'Lib/User/Profile/';
/**
* Request configuration file
*
* @var string
*
*/
private $conf = '';
/**
* Configuration file for validation
*
* @var string
* //
*/
private $verify = '';
/**
* Profile constructor.
*/
function __construct()
{
// Initialize request configuration and validate file path
$this->conf = Utils::getJson($this->jsonPath . 'api.json');
$this->verify = Utils::getJson($this->jsonPath . 'verify.json');
}
/**
* User profile settings
*
* @param array
* $params = [
* 'userId' => 'ujadk90ha1', // User ID
* 'userProfile' => [], // Basic user information (default maximum of 20 items)
* 'userExtProfile' => [] // Extended user information (key length does not exceed 32 characters, key must be prefixed with ext_, value length does not exceed 256 characters, default maximum of 20 items)
* ];
* @return array
*/
public function set(array $params = [])
{
$conf = $this->conf['set'];
$error = (new Utils())->check([
'api' => $conf,
'model' => 'profile',
'data' => $params,
'verify' => $this->verify['set']
]);
if ($error) return $error;
if (isset($params['userProfile'])) {
if (is_array($params['userProfile'])) {
$params['userProfile'] = json_encode($params['userProfile'], JSON_UNESCAPED_UNICODE);
}
}
if (isset($params['userExtProfile'])) {
if (is_array($params['userExtProfile'])) {
$params['userExtProfile'] = json_encode($params['userExtProfile'], JSON_UNESCAPED_UNICODE);
}
}
$result = (new Request())->Request($conf['url'], $params);
$result = (new Utils())->responseError($result, $conf['response']['fail']);
return $result;
}
/**
* User custody information clearance
*
* @param array
* $params = [
* 'userId'=> ['ujadk90ha1','ujadk90ha1'], // User ID list, up to 20 users at a time
* ];
* @return array
*/
public function clean(array $params = [])
{
$conf = $this->conf['clean'];
$error = (new Utils())->check([
'api' => $conf,
'model' => 'profile',
'data' => $params,
'verify' => $this->verify['clean']
]);
if ($error) return $error;
$result = (new Request())->Request($conf['url'], $params);
$result = (new Utils())->responseError($result, $conf['response']['fail']);
return $result;
}
/**
* Batch query user data
*
* @param array
* $params = [
* 'userId'=> ['ujadk90ha1','ujadk90ha1'],//User ID list, maximum 100 per batch
* ];
* @return array
*/
public function batchQuery(array $params = [])
{
$conf = $this->conf['batchQuery'];
$error = (new Utils())->check([
'api' => $conf,
'model' => 'profile',
'data' => $params,
'verify' => $this->verify['batchQuery']
]);
if ($error) return $error;
$result = (new Request())->Request($conf['url'], $params);
$result = (new Utils())->responseError($result, $conf['response']['fail']);
return $result;
}
/**
* Get paginated list of all application users
*
* @param array
* $params = [
* 'page' => 1, // Default is 1
* 'size' => 20, // Default is 20, maximum is 100
* 'order' => 0, // Sorting mechanism based on registration time, default is ascending, 0 for ascending, 1 for descending
* ];
* @return array
*/
public function query(array $params = [])
{
$conf = $this->conf['query'];
$error = (new Utils())->check([
'api' => $conf,
'model' => 'profile',
'data' => $params,
'verify' => $this->verify['query']
]);
if ($error) return $error;
$result = (new Request())->Request($conf['url'], $params);
$result = (new Utils())->responseError($result, $conf['response']['fail']);
return $result;
}
}