Skip to content

Commit 38530fa

Browse files
tomasperezvclayreimann
authored andcommitted
Implementing methods to retrieve list of followers and following users.
Github v3 provides the endpoints `followers` and `following` associated to the user entity. This change provides support for them and implements basic unit tests for them.
1 parent 9fb1f2f commit 38530fa

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

lib/User.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,26 @@ class User extends Requestable {
8181
return this._request('GET', this.__getScopedUrl('orgs'), null, cb);
8282
}
8383

84+
/**
85+
* List followers of a user
86+
* @see https://developer.github.com/v3/users/followers/#list-followers-of-a-user
87+
* @param {Requestable.callback} [cb] - will receive the list of followers
88+
* @return {Promise} - the promise for the http request
89+
*/
90+
listFollowers(cb) {
91+
return this._request('GET', this.__getScopedUrl('followers'), null, cb);
92+
}
93+
94+
/**
95+
* List users followed by another user
96+
* @see https://developer.github.com/v3/users/followers/#list-users-followed-by-another-user
97+
* @param {Requestable.callback} [cb] - will receive the list of who a user is following
98+
* @return {Promise} - the promise for the http request
99+
*/
100+
listFollowing(cb) {
101+
return this._request('GET', this.__getScopedUrl('following'), null, cb);
102+
}
103+
84104
/**
85105
* List the user's gists
86106
* @see https://developer.github.com/v3/gists/#list-a-users-gists

test/user.spec.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ describe('User', function() {
3434
user.listOrgs(assertArray(done));
3535
});
3636

37+
it('should get user followers', function(done) {
38+
user.listFollowers(assertArray(done));
39+
});
40+
41+
it('should get user following list', function(done) {
42+
user.listFollowing(assertArray(done));
43+
});
44+
3745
it('should get user gists', function(done) {
3846
user.listGists(assertArray(done));
3947
});

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