From 7f736a55e9a71b60045aed55ddc500999ea36a27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrique=20S=C3=A1?= Date: Mon, 27 Feb 2017 14:02:36 -0300 Subject: [PATCH 1/2] Added User.listEvents method --- lib/User.js | 20 ++++++++++++++++++++ test/user.spec.js | 4 ++++ 2 files changed, 24 insertions(+) diff --git a/lib/User.js b/lib/User.js index 3f3b4bb6..c084d682 100644 --- a/lib/User.js +++ b/lib/User.js @@ -111,6 +111,26 @@ class User extends Requestable { return this._request('GET', this.__getScopedUrl('notifications'), options, cb); } + /** + * List events for a user + * @see https://developer.github.com/v3/activity/events/#list-events-performed-by-a-user + * @param {object} options - the repository definition + * @param {Requestable.callback} [cb] - will receive the API response + * @return {Promise} - the promise for the http request + */ + listEvents(options, cb) { + options = options || {}; + if (typeof options === 'function') { + cb = options; + options = {}; + } + + options.since = this._dateToISO(options.since); + options.before = this._dateToISO(options.before); + + return this._request('GET', `/users/${this.__user}/events`, options, cb); + } + /** * Show the user's profile * @see https://developer.github.com/v3/users/#get-a-single-user diff --git a/test/user.spec.js b/test/user.spec.js index 2296781c..345ee7bc 100644 --- a/test/user.spec.js +++ b/test/user.spec.js @@ -42,6 +42,10 @@ describe('User', function() { user.listNotifications(assertArray(done)); }); + it('should get user activity', function(done) { + user.listEvents(assertArray(done)); + }); + it('should get user notifications with options', function(done) { const filterOpts = { all: true, From f16dc24bae39de277fe4ce10c9671b3fb7073284 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrique=20S=C3=A1?= Date: Mon, 27 Feb 2017 14:05:24 -0300 Subject: [PATCH 2/2] Fixed documentation for User.listEvents method --- lib/User.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/User.js b/lib/User.js index c084d682..13b344a7 100644 --- a/lib/User.js +++ b/lib/User.js @@ -114,7 +114,7 @@ class User extends Requestable { /** * List events for a user * @see https://developer.github.com/v3/activity/events/#list-events-performed-by-a-user - * @param {object} options - the repository definition + * @param {Object} [options={}] - any options to refine the search * @param {Requestable.callback} [cb] - will receive the API response * @return {Promise} - the promise for the http request */