Skip to content

Commit

Permalink
Issue #30
Browse files Browse the repository at this point in the history
Updated test scripts with new variables
  • Loading branch information
Brad Beebe committed Aug 21, 2014
1 parent e375daf commit 8a30130
Show file tree
Hide file tree
Showing 11 changed files with 96 additions and 90 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## v0.4.4
- Renamed the `limit` variable/property to `remaining` since it was using the `x-ratelimit-remaining` value.
- Assigned the `limit` variable/property to the `x-ratelimit-limit` API call response header value ([#30](https://github.com/teleportd/instagram-node/issues/30)).
- Adjusted the necessary functions to account for the new/renamed variables.

## v0.4.0
- Add support for new Instagram API security with `sign_request`

Expand All @@ -6,4 +11,4 @@
automatically set anymore. ([#23](https://github.com/teleportd/instagram-node/issues/23))
- Add `user_self_media_recent(options, cb)` to retrieve the medias posted by the
user related to the `access_token` being used. This is just an alias of
`user_media_recent(user_id, options, cb_)`.
`user_media_recent(user_id, options, cb_)`.
72 changes: 36 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,108 +117,108 @@ Once you've setup the API and/or authenticated, here is the full list of what yo
/********************************/
/* USERS */
/********************************/
ig.user('user_id', function(err, result, limit) {});
ig.user('user_id', function(err, result, remaining, limit) {});

/* OPTIONS: { [count], [min_id], [max_id] }; */
ig.user_self_feed([options,] function(err, medias, pagination, limit) {});
ig.user_self_feed([options,] function(err, medias, pagination, remaining, limit) {});

/* OPTIONS: { [count], [min_timestamp], [max_timestamp], [min_id], [max_id] }; */
ig.user_media_recent('user_id', [options,] function(err, medias, pagination, limit) {});
ig.user_media_recent('user_id', [options,] function(err, medias, pagination, remaining, limit) {});

/* OPTIONS: { [count], [min_timestamp], [max_timestamp], [min_id], [max_id] }; */
ig.user_self_media_recent([options,] function(err, medias, pagination, limit) {});
ig.user_self_media_recent([options,] function(err, medias, pagination, remaining, limit) {});

/* OPTIONS: { [count], [max_like_id] }; */
ig.user_self_liked([options,] function(err, medias, pagination, limit) {});
ig.user_self_liked([options,] function(err, medias, pagination, remaining, limit) {});

/* OPTIONS: { [count] }; */
ig.user_search('username', [options,] function(err, users, limit) {});
ig.user_search('username', [options,] function(err, users, remaining, limit) {});

/********************************/
/* RELATIONSHIP */
/********************************/
/* OPTIONS: { [count], [cursor] }; */
ig.user_follows('user_id', function(err, users, pagination, limit) {});
ig.user_follows('user_id', function(err, users, pagination, remaining, limit) {});

/* OPTIONS: { [count], [cursor] }; */
ig.user_followers('user_id', function(err, users, pagination, limit) {});
ig.user_followers('user_id', function(err, users, pagination, remaining, limit) {});

ig.user_self_requested_by(function(err, users, limit) {});
ig.user_self_requested_by(function(err, users, remaining, limit) {});

ig.user_relationship('user_id', function(err, result, limit) {});
ig.user_relationship('user_id', function(err, result, remaining, limit) {});

ig.set_user_relationship('user_id', 'follow', function(err, result, limit) {});
ig.set_user_relationship('user_id', 'follow', function(err, result, remaining, limit) {});

/********************************/
/* MEDIAS */
/********************************/
ig.media('media_id', function(err, media, limit) {});
ig.media('media_id', function(err, media, remaining, limit) {});

/* OPTIONS: { [min_timestamp], [max_timestamp], [distance] }; */
ig.media_search(48.4335645654, 2.345645645, [options,] function(err, medias, limit) {});
ig.media_search(48.4335645654, 2.345645645, [options,] function(err, medias, remaining, limit) {});

ig.media_popular(function(err, medias, limit) {});
ig.media_popular(function(err, medias, remaining, limit) {});

/********************************/
/* COMMENTS */
/********************************/
ig.comments('media_id', function(err, result, limit) {});
ig.comments('media_id', function(err, result, remaining, limit) {});

ig.add_comment('media_id', 'your comment', function(err, result, limit) {});
ig.add_comment('media_id', 'your comment', function(err, result, remaining, limit) {});

ig.del_comment('media_id', 'comment_id', function(err, limit) {});
ig.del_comment('media_id', 'comment_id', function(err, remaining, limit) {});

/********************************/
/* LIKES */
/********************************/
ig.likes('media_id', function(err, result, limit) {});
ig.likes('media_id', function(err, result, remaining, limit) {});

ig.add_like('media_id', function(err, limit) {});
ig.add_like('media_id', function(err, remaining, limit) {});

ig.del_like('media_id', function(err, limit) {});
ig.del_like('media_id', function(err, remaining, limit) {});

/********************************/
/* TAGS */
/********************************/
ig.tag('tag', function(err, result, limit) {});
ig.tag('tag', function(err, result, remaining, limit) {});

/* OPTIONS: { [min_tag_id], [max_tag_id] }; */
ig.tag_media_recent('tag', [options,] function(err, medias, pagination, limit) {});
ig.tag_media_recent('tag', [options,] function(err, medias, pagination, remaining, limit) {});

ig.tag_search('query', function(err, result, limit) {});
ig.tag_search('query', function(err, result, remaining, limit) {});

/********************************/
/* LOCATIONS */
/********************************/
ig.location('location_id', function(err, result, limit) {});
ig.location('location_id', function(err, result, remaining, limit) {});

/* OPTIONS: { [min_id], [max_id], [min_timestamp], [max_timestamp] }; */
ig.location_media_recent('location_id', [options,] function(err, result, pagination, limit) {});
ig.location_media_recent('location_id', [options,] function(err, result, pagination, remaining, limit) {});

/* SPECS: { lat, lng, [foursquare_v2_id], [foursquare_id] }; */
/* OPTIONS: { [distance] }; */
ig.location_search({ lat: 48.565464564, lng: 2.34656589 }, [options,] function(err, result, limit) {});
ig.location_search({ lat: 48.565464564, lng: 2.34656589 }, [options,] function(err, result, remaining, limit) {});

/********************************/
/* GEOGRAPHIES */
/********************************/
/* OPTIONS: { [min_id], [count] } */
ig.geography_media_recent(geography_id, [options,] function(err, result, pagination, limit) {});
ig.geography_media_recent(geography_id, [options,] function(err, result, pagination, remaining, limit) {});

/********************************/
/* SUBSCRIPTIONS */
/********************************/
ig.subscriptions(function(err, result, limit){});
ig.subscriptions(function(err, result, remaining, limit){});

ig.del_subscription({id:1}, function(err,subscriptions,limit){})

ig.add_tag_subscription('funny', 'http://MYHOST/tag/funny', function(err, result, limit){});
ig.add_tag_subscription('funny', 'http://MYHOST/tag/funny', function(err, result, remaining, limit){});

ig.add_geography_subscription(48.565464564, 2.34656589, 100, 'http://MYHOST/geography', function(err, result, limit){});
ig.add_geography_subscription(48.565464564, 2.34656589, 100, 'http://MYHOST/geography', function(err, result, remaining, limit){});

ig.add_user_subscription('http://MYHOST/user', function(err, result, limit){});
ig.add_user_subscription('http://MYHOST/user', function(err, result, remaining, limit){});

ig.add_location_subscription(1257285, 'http://MYHOST/location/1257285', function(err, result, limit){});
ig.add_location_subscription(1257285, 'http://MYHOST/location/1257285', function(err, result, remaining, limit){});
```

## Subscriptions
Expand All @@ -228,21 +228,21 @@ Subscriptions are callbacks from Instagram to your app when new things happen. T
You can get your subscriptions with this:

```javascript
ig.subscriptions(function(err, subscriptions, limit){
ig.subscriptions(function(err, subscriptions, remaining, limit){
console.log(subscriptions);
});
```

You can delete all your subscriptions with this:

```javascript
ig.del_subscription({ all: true }, function(err, subscriptions, limit){});
ig.del_subscription({ all: true }, function(err, subscriptions, remaining, limit){});
```

or just one with this:

```javascript
ig.del_subscription({ id: 1 }, function(err, subscriptions, limit){});
ig.del_subscription({ id: 1 }, function(err, subscriptions, remaining, limit){});
```


Expand Down Expand Up @@ -272,7 +272,7 @@ is basically the same that Instagram would give you but there will be a `next()`
```javascript
var ig = require('instagram-node').instagram();

var hdl = function(err, result, pagination, limit) {
var hdl = function(err, result, pagination, remaining, limit) {
// Your implementation here
if(pagination.next) {
pagination.next(hdl); // Will get second page results
Expand Down
15 changes: 8 additions & 7 deletions lib/instagram.js
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ var instagram = function(spec, my) {
if(err) {
return handle_error(err, cb, retry);
} else if(result && result.meta && result.meta.code === 200) {
return cb(null, result.data, remaining, remaining, limit);
return cb(null, result.data, remaining, limit);
} else {
return handle_error(result, cb, retry);
}
Expand Down Expand Up @@ -836,7 +836,7 @@ var instagram = function(spec, my) {
if(err) {
return handle_error(err, cb, retry);
} else if(result && result.meta && result.meta.code === 200) {
return cb(null, result.data, remaining, remaining, limit);
return cb(null, result.data, remaining, limit);
} else {
return handle_error(result, cb, retry);
}
Expand All @@ -856,7 +856,7 @@ var instagram = function(spec, my) {
if(err) {
return handle_error(err, cb, retry);
} else if(result && result.meta && result.meta.code === 200) {
return cb(null, result.data, remaining, remaining, limit);
return cb(null, result.data, remaining, limit);
} else {
return handle_error(result, cb, retry);
}
Expand All @@ -881,7 +881,7 @@ var instagram = function(spec, my) {
if(err) {
return handle_error(err, cb, retry);
} else if(result && result.meta && result.meta.code === 200) {
return cb(null, result.data, remaining, remaining, limit);
return cb(null, result.data, remaining, limit);
} else {
return handle_error(result, cb, retry);
}
Expand Down Expand Up @@ -923,7 +923,7 @@ var instagram = function(spec, my) {
if(err) {
return handle_error(err, cb, retry);
} else if(result && result.meta && result.meta.code === 200) {
return cb(null, result.data, remaining, remaining, limit);
return cb(null, result.data, remaining, limit);
} else {
return handle_error(result, cb, retry);
}
Expand Down Expand Up @@ -964,7 +964,7 @@ var instagram = function(spec, my) {
if(err) {
return handle_error(err, cb, retry);
} else if(result && result.meta && result.meta.code === 200) {
return cb(null, remaining, remaining, limit);
return cb(null, remaining, limit);
} else {
return handle_error(result, cb, retry);
}
Expand All @@ -989,7 +989,7 @@ var instagram = function(spec, my) {
if(err) {
return handle_error(err, cb, retry);
} else if(result && result.meta && result.meta.code === 200) {
return cb(null, result.data, remaining, remaining, limit);
return cb(null, result.data, remaining, limit);
} else {
return handle_error(result, cb, retry);
}
Expand Down Expand Up @@ -1681,6 +1681,7 @@ var instagram = function(spec, my) {
fwk.method(that, 'add_location_subscription', add_location_subscription, _super);

fwk.getter(that, 'limit', my, 'limit');
fwk.getter(that, 'remaining', my, 'remaining');

return that;
};
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "instagram-node",
"version": "0.4.3",
"version": "0.4.4",
"description": "Simple Instagram driver for Node.js",
"keywords": ["instagram", "node", "ig", "driver"],
"homepage": "https://github.com/teleportd/instagram-node",
Expand Down
4 changes: 2 additions & 2 deletions test/scripts/comments.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ var comments = (function(spec, my) {
var tests = {
'comments': function(cb_) {
var retry = 0;
instagram.comments('318869204166248215_33082304', function(err, result, limit) {
instagram.comments('318869204166248215_33082304', function(err, result, remaining, limit) {
var res = {
ok: true,
description: 'Retrieves comments'
};

if(result && limit) {
if(result && remaining) {
return cb_(null, res);
} else {
if(retry < 2) {
Expand Down
14 changes: 7 additions & 7 deletions test/scripts/likes.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ var likes = (function(spec, my) {
var tests = {
'likes': function(cb_) {
var retry = 0;
instagram.likes('318869204166248215_33082304', function(err, result, limit) {
instagram.likes('318869204166248215_33082304', function(err, result, remaining, limit) {
var res = {
ok: true,
description: 'Retrieves likes'
};

if(result && limit) {
if(result && remaining) {
return cb_(null, res);
} else {
if(retry < 2) {
Expand All @@ -45,13 +45,13 @@ var likes = (function(spec, my) {
},
'add like': function(cb_) {
var retry = 0;
instagram.add_like('318869204166248215_33082304', function(err, limit) {
instagram.add_like('318869204166248215_33082304', function(err, remaining, limit) {
var res = {
ok: true,
description: 'Add a like'
};
if(!err && limit) {

if(!err && remaining) {
return cb_(null, res);
} else {
if(retry < 2) {
Expand All @@ -66,13 +66,13 @@ var likes = (function(spec, my) {
},
'del like': function(cb_) {
var retry = 0;
instagram.del_like('318869204166248215_33082304', function(err, limit) {
instagram.del_like('318869204166248215_33082304', function(err, remaining, limit) {
var res = {
ok: true,
description: 'Delete a like'
};

if(!err && limit) {
if(!err && remaining) {
return cb_(null, res);
} else {
if(retry < 2) {
Expand Down
12 changes: 6 additions & 6 deletions test/scripts/locations.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ var locations = (function(spec, my) {
var tests = {
'location': function(cb_) {
var retry = 0;
instagram.location('7351364', function(err, result, limit) {
instagram.location('7351364', function(err, result, remaining, limit) {
var res = {
ok: true,
description: 'Retrieves a location'
};

if(result && limit) {
if(result && remaining) {
return cb_(null, res);
} else {
if(retry < 2) {
Expand All @@ -45,13 +45,13 @@ var locations = (function(spec, my) {
},
'location search': function(cb_) {
var retry = 0;
instagram.location_search({ lat: 48.858831776042265, lng: 2.3470598999999766, distance: 5000 }, function(err, result, limit) {
instagram.location_search({ lat: 48.858831776042265, lng: 2.3470598999999766, distance: 5000 }, function(err, result, remaining, limit) {
var res = {
ok: true,
description: 'Search a location'
};

if(result && limit) {
if(result && remaining) {
return cb_(null, res);
} else {
if(retry < 2) {
Expand All @@ -66,13 +66,13 @@ var locations = (function(spec, my) {
},
'location media recent': function(cb_) {
var retry = 0;
instagram.location_media_recent('7351364', function(err, result, limit) {
instagram.location_media_recent('7351364', function(err, result, remaining, limit) {
var res = {
ok: true,
description: 'Retrieves location recent medias'
};

if(result && limit) {
if(result && remaining) {
return cb_(null, res);
} else {
if(retry < 2) {
Expand Down
Loading

0 comments on commit 8a30130

Please sign in to comment.