File tree 5 files changed +75
-1
lines changed
5 files changed +75
-1
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,13 @@ $activity = $client->api('current_user')->starring()->all();
31
31
```
32
32
Returns an array of starred repos.
33
33
34
+ ### Get list of private and public events for an authenticated user for all repos
35
+
36
+ ``` php
37
+ $activity = $client->api('user')->events('ornicar');
38
+ ```
39
+ Returns an array of private and public events created for all repos related to the user.
40
+
34
41
### Get repos that a authenticated user has starred with creation date
35
42
36
43
Support for getting the star creation timestamp in the response, using the custom ` Accept: application/vnd.github.v3.star+json ` header.
@@ -100,4 +107,4 @@ $owner = "KnpLabs";
100
107
$repo = "php-github-api";
101
108
$activity = $client->api('current_user')->watchers()->unwatch($owner, $repo);
102
109
```
103
- Throws an Exception in case of failure or NULL in case of success.
110
+ Throws an Exception in case of failure or NULL in case of success.
Original file line number Diff line number Diff line change @@ -148,6 +148,17 @@ $users = $client->api('current_user')->starring()->all();
148
148
149
149
Returns an array of starred repos.
150
150
151
+ ### Get the authenticated user activity
152
+
153
+ > Requires [ authentication] ( security.md ) .
154
+
155
+ ``` php
156
+ $activity = $client->api('user')->events('ornicar');
157
+ ```
158
+
159
+ Returns an array of private and public events created for all repos related to the user.
160
+ > See [ more] ( activity.md ) .
161
+
151
162
### Get the authenticated user emails
152
163
153
164
> Requires [ authentication] ( security.md ) .
Original file line number Diff line number Diff line change @@ -234,4 +234,16 @@ public function publicEvents($username)
234
234
{
235
235
return $ this ->get ('/users/ ' .rawurlencode ($ username ).'/events/public ' );
236
236
}
237
+
238
+ /**
239
+ * List events performed by an authenticated user.
240
+ *
241
+ * @link https://docs.github.com/en/rest/reference/activity#list-events-for-the-authenticated-user
242
+ *
243
+ * @return array
244
+ */
245
+ public function events (string $ username )
246
+ {
247
+ return $ this ->get ('/users/ ' .rawurlencode ($ username ).'/events ' );
248
+ }
237
249
}
Original file line number Diff line number Diff line change @@ -228,6 +228,29 @@ public function shouldGetUserGists()
228
228
$ this ->assertEquals ($ expectedArray , $ api ->gists ('l3l0 ' ));
229
229
}
230
230
231
+ /**
232
+ * @test
233
+ */
234
+ public function shouldGetAuthorizedUserEvents ()
235
+ {
236
+ $ expectedArray = [
237
+ [
238
+ 'id ' => 1 ,
239
+ 'actor ' => [
240
+ 'id ' => 1 ,
241
+ 'login ' => 'l3l0 ' ,
242
+ ],
243
+ ],
244
+ ];
245
+ $ api = $ this ->getApiMock ();
246
+ $ api ->expects ($ this ->once ())
247
+ ->method ('get ' )
248
+ ->with ('/users/l3l0/events ' )
249
+ ->will ($ this ->returnValue ($ expectedArray ));
250
+
251
+ $ this ->assertEquals ($ expectedArray , $ api ->events ('l3l0 ' ));
252
+ }
253
+
231
254
/**
232
255
* @return string
233
256
*/
Original file line number Diff line number Diff line change @@ -138,4 +138,25 @@ public function shouldGetReposBeingStarred()
138
138
$ this ->assertArrayHasKey ('git_url ' , $ repo );
139
139
$ this ->assertArrayHasKey ('svn_url ' , $ repo );
140
140
}
141
+
142
+ /**
143
+ * @test
144
+ */
145
+ public function shouldGetEventsForAuthenticatedUserBeignWatched ()
146
+ {
147
+ $ username = 'l3l0 ' ;
148
+
149
+ $ events = $ this ->client ->api ('user ' )->events ($ username );
150
+ $ event = array_pop ($ events );
151
+
152
+ $ this ->assertArrayHasKey ('id ' , $ event );
153
+ $ this ->assertArrayHasKey ('type ' , $ event );
154
+ $ this ->assertArrayHasKey ('actor ' , $ event );
155
+ $ this ->assertArrayHasKey ('login ' , $ event ['actor ' ]);
156
+ $ this ->assertArrayHasKey ('repo ' , $ event );
157
+ $ this ->assertArrayHasKey ('name ' , $ event ['repo ' ]);
158
+ $ this ->assertArrayHasKey ('payload ' , $ event );
159
+ $ this ->assertArrayHasKey ('public ' , $ event );
160
+ $ this ->assertArrayHasKey ('created_at ' , $ event );
161
+ }
141
162
}
You can’t perform that action at this time.
0 commit comments