Skip to content

Commit 444ad22

Browse files
committed
Implement More Gist APIs
1 parent df3c80f commit 444ad22

File tree

2 files changed

+41
-8
lines changed

2 files changed

+41
-8
lines changed

example/status.dart

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,11 @@ sync() async {
1111
"Origin": window.location.origin
1212
});
1313

14-
15-
1614
var text = request.responseText;
1715
var json = JSON.decode(text);
1816

1917
querySelector("#status")
2018
..appendText(json["status"])
2119
..classes.add("status-${json["status"]}");
2220
}
23-
2421
}

lib/src/common/gists_service.dart

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,16 @@ class GistsService extends Service {
7575
return _github.postJSON("/gists", statusCode: 201, body: JSON.encode(map), convert: Gist.fromJSON);
7676
}
7777

78+
/// Deletes the specified Gist.
79+
///
80+
/// API docs: https://developer.github.com/v3/gists/#delete-a-gist
7881
Future<bool> deleteGist(String id) {
7982
return _github.request("DELETE", "/gists/${id}").then((response) {
8083
return response.statusCode == 204;
8184
});
8285
}
8386

84-
/// Edits a Gist
87+
/// Edits a Gist.
8588
///
8689
/// API docs: https://developer.github.com/v3/gists/#edit-a-gist
8790
Future<Gist> editGist(Map<String, String> files, {String description, bool public: false}) {
@@ -109,10 +112,43 @@ class GistsService extends Service {
109112
}
110113

111114
// TODO: Implement listGistCommits: https://developer.github.com/v3/gists/#list-gist-commits
112-
// TODO: Implement starGist: https://developer.github.com/v3/gists/#star-a-gist
113-
// TODO: Implement unstarGist: https://developer.github.com/v3/gists/#unstar-a-gist
114-
// TODO: Implement isStarredGist: https://developer.github.com/v3/gists/#check-if-a-gist-is-starred
115-
// TODO: Implement forkGist: https://developer.github.com/v3/gists/#fork-a-gist
115+
116+
/// Star the specified Gist.
117+
///
118+
/// API docs: https://developer.github.com/v3/gists/#star-a-gist
119+
Future<bool> starGist(String id) {
120+
return _github.request("POST", "/gists/${id}/star").then((response) {
121+
return response.statusCode == 204;
122+
});
123+
}
124+
125+
/// Unstar the specified Gist.
126+
///
127+
/// API docs: https://developer.github.com/v3/gists/#star-a-gist
128+
Future<bool> unstarGist(String id) {
129+
return _github.request("DELETE", "/gists/${id}/star").then((response) {
130+
return response.statusCode == 204;
131+
});
132+
}
133+
134+
/// Checks if the specified Gist is starred.
135+
///
136+
/// API docs: https://developer.github.com/v3/gists/#check-if-a-gist-is-starred
137+
Future<bool> isGistStarred(String id) {
138+
return _github.request("GET", "/gists/${id}/star").then((response) {
139+
return response.statusCode == 204;
140+
});
141+
}
142+
143+
/// Forks the specified Gist.
144+
///
145+
/// API docs: https://developer.github.com/v3/gists/#check-if-a-gist-is-starred
146+
Future<Gist> forkGist(String id) {
147+
return _github.request("POST", "/gists/${id}/forks", statusCode: 201).then((response) {
148+
return Gist.fromJSON(response.asJSON());
149+
});
150+
}
151+
116152
// TODO: Implement listGistForks: https://developer.github.com/v3/gists/#list-gist-forks
117153

118154
/// Lists all comments for a gist.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy