-
-
Notifications
You must be signed in to change notification settings - Fork 598
/
Copy pathUser.php
264 lines (247 loc) · 8.01 KB
/
User.php
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
<?php
namespace Github\Api;
/**
* Searching users, getting user information.
*
* @link http://developer.github.com/v3/users/
*
* @author Joseph Bielawski <[email protected]>
* @author Thibault Duplessis <thibault.duplessis at gmail dot com>
*/
class User extends AbstractApi
{
/**
* Request all users.
*
* @link https://developer.github.com/v3/users/#get-all-users
*
* @param int|null $id ID of the last user that you've seen
*
* @return array list of users found
*/
public function all($id = null)
{
if (!is_int($id)) {
return $this->get('/users');
}
return $this->get('/users', ['since' => $id]);
}
/**
* Get extended information about a user by its username.
*
* @link http://developer.github.com/v3/users/
*
* @param string $username the username to show
*
* @return array information about the user
*/
public function show($username)
{
return $this->get('/users/'.rawurlencode($username));
}
/**
* Get extended information about a user by its id.
* Note: at time of writing this is an undocumented feature but GitHub support have advised that it can be relied on.
*
* @link http://developer.github.com/v3/users/
*
* @param int $id the id of the user to show
*
* @return array information about the user
*/
public function showById($id)
{
return $this->get('/user/'.$id);
}
/**
* Get extended information about a user by its username.
*
* @link https://developer.github.com/v3/orgs/
*
* @param string $username the username to show
*
* @return array information about organizations that user belongs to
*/
public function organizations($username)
{
return $this->get('/users/'.rawurlencode($username).'/orgs');
}
/**
* Get user organizations.
*
* @link https://developer.github.com/v3/orgs/#list-your-organizations
*
* @return array information about organizations that authenticated user belongs to
*/
public function orgs()
{
return $this->get('/user/orgs');
}
/**
* Request the users that a specific user is following.
*
* @link http://developer.github.com/v3/users/followers/
*
* @param string $username the username
* @param array $parameters parameters for the query string
* @param array $requestHeaders additional headers to set in the request
*
* @return array list of followed users
*/
public function following($username, array $parameters = [], array $requestHeaders = [])
{
return $this->get('/users/'.rawurlencode($username).'/following', $parameters, $requestHeaders);
}
/**
* Request the users following a specific user.
*
* @link http://developer.github.com/v3/users/followers/
*
* @param string $username the username
* @param array $parameters parameters for the query string
* @param array $requestHeaders additional headers to set in the request
*
* @return array list of following users
*/
public function followers($username, array $parameters = [], array $requestHeaders = [])
{
return $this->get('/users/'.rawurlencode($username).'/followers', $parameters, $requestHeaders);
}
/**
* Request starred repositories that a specific user has starred.
*
* @link http://developer.github.com/v3/activity/starring/
*
* @param string $username the username
* @param int $page the page number of the paginated result set
* @param int $perPage the number of results per page
* @param string $sort sort by (possible values: created, updated)
* @param string $direction direction of sort (possible values: asc, desc)
*
* @return array list of starred repositories
*/
public function starred($username, $page = 1, $perPage = 30, $sort = 'created', $direction = 'desc')
{
return $this->get('/users/'.rawurlencode($username).'/starred', [
'page' => $page,
'per_page' => $perPage,
'sort' => $sort,
'direction' => $direction,
]);
}
/**
* Request the repository that a specific user is watching.
*
* @link http://developer.github.com/v3/activity/watching/
*
* @param string $username the username
*
* @return array list of watched repositories
*/
public function subscriptions($username)
{
return $this->get('/users/'.rawurlencode($username).'/subscriptions');
}
/**
* List public repositories for the specified user.
*
* @link https://developer.github.com/v3/repos/#list-user-repositories
*
* @param string $username the username
* @param string $type role in the repository (Deprecated)
* @param string $sort sort by (Deprecated)
* @param string $direction direction of sort, asc or desc (Deprecated)
* @param string $visibility visibility of repository (Deprecated)
* @param string $affiliation relationship to repository (Deprecated)
* @param array $params e.g. e.g. [
* 'type' => 'owner',
* 'sort' => 'full_name',
* 'direction'=> 'asc',
* 'visibility' => 'all',
* 'affiliation' => 'owner,collaborator,organization_member',
* 'per_page' => 50,
* ]
*
* @return array list of the user repositories
*/
public function repositories(
string $username,
$type = 'owner',
$sort = 'full_name',
$direction = 'asc',
$visibility = 'all',
$affiliation = 'owner,collaborator,organization_member',
array $params = []
) {
return $this->get('/users/'.rawurlencode($username).'/repos', array_merge([
'type' => $type,
'sort' => $sort,
'direction' => $direction,
'visibility' => $visibility,
'affiliation' => $affiliation,
], $params));
}
/**
* List repositories that are accessible to the authenticated user.
*
* @link https://developer.github.com/v3/repos/#list-your-repositories
*
* @param array $params visibility, affiliation, type, sort, direction
*
* @return array list of the user repositories
*/
public function myRepositories(array $params = [])
{
return $this->get('/user/repos', $params);
}
/**
* Get the public gists for a user.
*
* @link http://developer.github.com/v3/gists/
*
* @param string $username the username
*
* @return array list of the user gists
*/
public function gists($username)
{
return $this->get('/users/'.rawurlencode($username).'/gists');
}
/**
* Get the public keys for a user.
*
* @link http://developer.github.com/v3/users/keys/#list-public-keys-for-a-user
*
* @param string $username the username
*
* @return array list of the user public keys
*/
public function keys($username)
{
return $this->get('/users/'.rawurlencode($username).'/keys');
}
/**
* List events performed by a user.
*
* @link http://developer.github.com/v3/activity/events/#list-public-events-performed-by-a-user
*
* @param string $username
*
* @return array
*/
public function publicEvents($username)
{
return $this->get('/users/'.rawurlencode($username).'/events/public');
}
/**
* List events performed by an authenticated user.
*
* @link https://docs.github.com/en/rest/reference/activity#list-events-for-the-authenticated-user
*
* @return array
*/
public function events(string $username)
{
return $this->get('/users/'.rawurlencode($username).'/events');
}
}