From c56526829e57d01ca23ce1700b83d28356021a72 Mon Sep 17 00:00:00 2001 From: Jose Junior Date: Wed, 20 Dec 2017 21:13:02 -0200 Subject: [PATCH] Added user_self method --- lib/instagram.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/lib/instagram.js b/lib/instagram.js index 77cdba1..cf79570 100644 --- a/lib/instagram.js +++ b/lib/instagram.js @@ -49,6 +49,7 @@ var instagram = function(spec, my) { var use; /* use(spec); */ var user; /* user(user_id, cb); */ + var user_self; /* user(options, cb); */ var user_self_feed; /* user_self_feed(options, cb); */ var user_media_recent; /* user_media_recent(user_id, options, cb); */ var user_self_media_recent; /* user_self_media_recent(options, cb); */ @@ -372,6 +373,34 @@ var instagram = function(spec, my) { }, retry); }; + /** + * Retrieves information about the current user + * @param options object { count, [opt] + * min_id, [opt] + * max_id [opt] } + * @param cb function (err, user, remaining, limit); + */ + user_self = function(options, cb) { + var retry = function() { + user_self(options, cb); + }; + + if(!cb && typeof options === 'function') { + cb = options; + options = {}; + } + + call('GET', '/users/self', {}, function(err, result, remaining, limit) { + if(err) { + return handle_error(err, cb, retry); + } else if(result && result.meta && result.meta.code === 200) { + return cb(null, result.data, remaining, limit); + } else { + return handle_error(result, cb, retry); + } + }, retry); + }; + /** * Retrieves the current user feed * @param options object { count, [opt] @@ -1741,6 +1770,7 @@ var instagram = function(spec, my) { fwk.method(that, 'use', use, _super); fwk.method(that, 'user', user, _super); + fwk.method(that, 'user_self', user_self, _super); fwk.method(that, 'user_self_feed', user_self_feed, _super); fwk.method(that, 'user_media_recent', user_media_recent, _super); fwk.method(that, 'user_self_media_recent', user_self_media_recent, _super);