-
-
Notifications
You must be signed in to change notification settings - Fork 600
/
CurrentUser.php
193 lines (168 loc) · 4.78 KB
/
CurrentUser.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
<?php
namespace Github\Api;
use Github\Api\CurrentUser\Emails;
use Github\Api\CurrentUser\Followers;
use Github\Api\CurrentUser\Memberships;
use Github\Api\CurrentUser\Notifications;
use Github\Api\CurrentUser\PublicKeys;
use Github\Api\CurrentUser\Starring;
use Github\Api\CurrentUser\Watchers;
/**
* @link http://developer.github.com/v3/users/
*
* @author Joseph Bielawski <[email protected]>
* @author Felipe Valtl de Mello <[email protected]>
*/
class CurrentUser extends AbstractApi
{
use AcceptHeaderTrait;
public function show()
{
return $this->get('/user');
}
public function update(array $params)
{
return $this->patch('/user', $params);
}
/**
* @return Emails
*/
public function emails()
{
return new Emails($this->getClient());
}
/**
* @return Followers
*/
public function follow()
{
return new Followers($this->getClient());
}
public function followers($page = 1)
{
return $this->get('/user/followers', [
'page' => $page,
]);
}
/**
* @link https://docs.github.com/en/rest/reference/issues#list-user-account-issues-assigned-to-the-authenticated-user
*
* @param array $params
* @param bool $includeOrgIssues
*
* @return array
*/
public function issues(array $params = [], $includeOrgIssues = true)
{
return $this->get($includeOrgIssues ? '/issues' : '/user/issues', array_merge(['page' => 1], $params));
}
/**
* @return PublicKeys
*/
public function keys()
{
return new PublicKeys($this->getClient());
}
/**
* @return Notifications
*/
public function notifications()
{
return new Notifications($this->getClient());
}
/**
* @return Memberships
*/
public function memberships()
{
return new Memberships($this->getClient());
}
/**
* @link https://docs.github.com/en/rest/reference/orgs#list-organizations-for-the-authenticated-user
*
* @return array
*/
public function organizations()
{
return $this->get('/user/orgs');
}
/**
* @link https://developer.github.com/v3/orgs/teams/#list-user-teams
*
* @return array
*/
public function teams()
{
return $this->get('/user/teams');
}
/**
* @link https://docs.github.com/en/rest/reference/repos#list-repositories-for-the-authenticated-user
*
* @param string $type role in the repository
* @param string $sort sort by
* @param string $direction direction of sort, asc or desc
* @param string $visibility visibility of repository
* @param string $affiliation relationship to repository
*
* @return array
*/
public function repositories($type = 'owner', $sort = 'full_name', $direction = 'asc', $visibility = null, $affiliation = null)
{
$params = [
'type' => $type,
'sort' => $sort,
'direction' => $direction,
];
if (null !== $visibility) {
unset($params['type']);
$params['visibility'] = $visibility;
}
if (null !== $affiliation) {
unset($params['type']);
$params['affiliation'] = $affiliation;
}
return $this->get('/user/repos', $params);
}
/**
* @return Watchers
*/
public function watchers()
{
return new Watchers($this->getClient());
}
/**
* @return Starring
*/
public function starring()
{
return new Starring($this->getClient());
}
/**
* @link https://docs.github.com/en/rest/reference/activity#list-repositories-watched-by-the-authenticated-user
*/
public function subscriptions()
{
return $this->get('/user/subscriptions');
}
/**
* @link https://docs.github.com/en/rest/reference/apps#list-app-installations-accessible-to-the-user-access-token
*
* @param array $params
*/
public function installations(array $params = [])
{
$this->acceptHeaderValue = 'application/vnd.github.machine-man-preview+json';
return $this->get('/user/installations', array_merge(['page' => 1], $params));
}
/**
* @link https://developer.github.com/v3/apps/installations/#list-repositories-accessible-to-the-user-access-token
*
* @param string $installationId the ID of the Installation
* @param array $params
*/
public function repositoriesByInstallation($installationId, array $params = [])
{
$this->acceptHeaderValue = 'application/vnd.github.machine-man-preview+json';
return $this->get(sprintf('/user/installations/%s/repositories', $installationId), array_merge(['page' => 1], $params));
}
}