Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added user_self method #123

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions lib/instagram.js
Original file line number Diff line number Diff line change
Expand Up @@ -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); */
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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);
Expand Down