@@ -310,6 +310,53 @@ class GitHub {
310
310
return copyOf (input.map ((it) => Gist .fromJSON (github, it)));
311
311
});
312
312
}
313
+
314
+ /**
315
+ * Fetches the Stargazers for a Repository
316
+ *
317
+ * [slug] is a repository slug.
318
+ */
319
+ Future <List <User >> stargazers (RepositorySlug slug) {
320
+ return getJSON ("/repos/${slug .fullName }/stargazers" , statusCode: 200 , convert: (GitHub github, List <dynamic > input) {
321
+ return copyOf (input.map ((it) => User .fromJSON (github, it)));
322
+ });
323
+ }
324
+
325
+ /**
326
+ * Fetches the repositories that [user] has starred.
327
+ */
328
+ Future <List <Repository >> starred (String user) {
329
+ return getJSON ("/users/${user }/starred" , statusCode: 200 , convert: (GitHub github, List <dynamic > input) {
330
+ return copyOf (input.map ((it) => Repository .fromJSON (github, it)));
331
+ });
332
+ }
333
+
334
+ /**
335
+ * Checks if the currently authenticated user has starred the specified repository.
336
+ */
337
+ Future <bool > hasStarred (RepositorySlug slug) {
338
+ return request ("GET" , "/user/starred/${slug .fullName }" ).then ((response) {
339
+ return response.statusCode == 204 ;
340
+ });
341
+ }
342
+
343
+ /**
344
+ * Stars the specified repository for the currently authenticated user.
345
+ */
346
+ Future star (RepositorySlug slug) {
347
+ return request ("PUT" , "/user/starred/${slug .fullName }" , headers: { "Content-Length" : 0 }).then ((response) {
348
+ return null ;
349
+ });
350
+ }
351
+
352
+ /**
353
+ * Unstars the specified repository for the currently authenticated user.
354
+ */
355
+ Future unstar (RepositorySlug slug) {
356
+ return request ("DELETE" , "/user/starred/${slug .fullName }" , headers: { "Content-Length" : 0 }).then ((response) {
357
+ return null ;
358
+ });
359
+ }
313
360
314
361
/**
315
362
* Handles Get Requests that respond with JSON
0 commit comments