Skip to content
Browse files

Added subscription posts method

  • Loading branch information...
1 parent fec57bf commit b10b6e4652a578f08a557f36939662aedde9a123 @andzdroid committed Jun 11, 2011
Showing with 38 additions and 7 deletions.
  1. +18 −1 lib/posterous.js
  2. +20 −6 tests/subscriptions.js
View
19 lib/posterous.js
@@ -100,7 +100,7 @@ Posterous.prototype.getUser = function getCurrentUser(callback) {
//Subscriptions
-//getSubscriptions([page number], callback)
+//getSubscriptions([page number,] callback)
//Use as getSubscriptions(2, callback) for page 2 of subscriptions
//Or getSubscriptions(callback) for page 1 of subcriptions
Posterous.prototype.getSubscriptions = function getSubscriptions(page, callback) {
@@ -118,4 +118,21 @@ Posterous.prototype.getSubscriptions = function getSubscriptions(page, callback)
});
};
+Posterous.prototype.getSubscriptionPosts = function getSubscriptionPosts(page, callback) {
+ if (callback == undefined) {
+ callback = page;
+ page = 1;
+ }
+
+ this.request('GET', 'users/me/subscriptions/posts', {page: page}, function(err, result) {
+ if (err) {
+ return callback(err);
+ }
+
+ callback(null, result);
+ });
+};
+
+
+
module.exports = Posterous;
View
26 tests/subscriptions.js
@@ -16,12 +16,19 @@ module.exports['Subscribed Sites'] = function(test) {
test.ok(result, 'Could not retrieve the user\'s subscriptions');
- test.done();
+ console.log('Fetching page 2 of subscriptions...');
+ posterous.getSubscriptions(2, function(err, result) {
+ test.ok(!err, 'An error occurred: ' + err);
+
+ test.ok(result, 'Coudl not retrieve page 2 of subscriptions');
+
+ test.done();
+ });
});
});
};
-module.exports['Subscribed Sites Page 2'] = function(test) {
+module.exports['Subscription Posts'] = function(test) {
var posterous = new Posterous(config.user, config.pass);
console.log('Fetching api token...');
@@ -30,13 +37,20 @@ module.exports['Subscribed Sites Page 2'] = function(test) {
test.ok(!err, 'Could not get api token, check your username/password in config/index.js');
}
- console.log('Fetching page 2 of subscriptions...');
- posterous.getSubscriptions(2, function(err, result) {
+ console.log('Fetching page 1 of subscription posts...');
+ posterous.getSubscriptionPosts(function(err, result) {
test.ok(!err, 'An error occurred: ' + err);
- test.ok(result, 'Could not retrieve page 2 of the user\'s subscriptions');
+ test.ok(result, 'Could not retrieve page 1 of subscription posts');
+
+ console.log('Fetching page 2 of subscription posts...');
+ posterous.getSubscriptionPosts(2, function(err, result) {
+ test.ok(!err, 'An error occurred: ' + err);
+
+ test.ok(result, 'Could not retrieve page 2 of posts');
- test.done();
+ test.done();
+ });
});
});
};

0 comments on commit b10b6e4

Please sign in to comment.
Something went wrong with that request. Please try again.