Skip to content

Commit cd26446

Browse files
knsh14clayreimann
authored andcommitted
feature(User): Add List starred gists API (#475)
* get list of starred gist api
1 parent dcc3472 commit cd26446

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

lib/User.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,23 @@ class User extends Requestable {
132132
return this._requestAllPages(this.__getScopedUrl('starred'), requestOptions, cb);
133133
}
134134

135+
/**
136+
* Gets the list of starred gists for the user
137+
* @see https://developer.github.com/v3/gists/#list-starred-gists
138+
* @param {Object} [options={}] - any options to refine the search
139+
* @param {Requestable.callback} [cb] - will receive the list of gists
140+
* @return {Promise} - the promise for the http request
141+
*/
142+
listStarredGists(options, cb) {
143+
options = options || {};
144+
if (typeof options === 'function') {
145+
cb = options;
146+
options = {};
147+
}
148+
options.since = this._dateToISO(options.since);
149+
return this._request('GET', '/gists/starred', options, cb);
150+
}
151+
135152
/**
136153
* List email addresses for a user
137154
* @see https://developer.github.com/v3/users/emails/#list-email-addresses-for-a-user

test/user.spec.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@ describe('User', function() {
6161
user.listStarredRepos(assertArray(done));
6262
});
6363

64+
it('should show user\'s starred gists', function(done) {
65+
const option = {
66+
since: '2015-01-01T00:00:00Z',
67+
};
68+
user.listStarredGists(option, assertArray(done));
69+
});
70+
6471
it('should follow user', function(done) {
6572
user.follow('ingalls', assertSuccessful(done));
6673
});

0 commit comments

Comments
 (0)