Permalink
Browse files

Added more api methods: photos, subscribe, header image, tags

  • Loading branch information...
1 parent 5b8822f commit e19533c39d095a9f58e5fe3b8f5dbc52fc87870f @andzdroid committed Jun 14, 2011
Showing with 85 additions and 0 deletions.
  1. +20 −0 README.md
  2. +65 −0 lib/posterous.js
20 README.md
@@ -87,3 +87,23 @@ The result will be in the same format as the data returned by `getSites`.
### deleteSite(id, callback)
`deleteSite` deletes the Posterous site specified by the *site id*. This method corresponds to the API endpoint `sites/:id`.
+
+### getPhotos(id, options, callback)
+`getPhotos` gets 20 random photos from a Posterous specified by the *site id*. This method corresponds to the API endpoint `sites/:id/photos`.
+
+The possible keys in the `options` dictionary are `page` which determines which page of photos to return, and `since_id`, which will restrict photos to those attached to posts after the post with the provided ID. (See API docs for more info)
+
+### subscribe(id, callback)
+`subscribe` subscribes the current user to the site specified by the *site id*. This method corresponds to the API endpoint `sites/:id/subscribe`.
+
+### unsubscribe(id, callback)
+`unsubscribe` removes the user's subscription to the site specified by the *site id*. This method corresponds to the API endpoint `sites/:id/unsubscribe`.
+
+### setHeader(id, file, callback)
+`setHeader` sets a new header image for the site. This method corresponds to the API endpoint `sites/:id/header_image`.
+
+### deleteHeader(id, callback)
+`deleteHeader` removes the header image for the site specified by the *site id*. This method corresponds to the API endpoint `sites/:id/header_image`.
+
+### getTags(id, callback)
+`getTags` retrieves the tags associated with a site. This method corresponds to the API endpoint `sites/:id/tags`.
View
65 lib/posterous.js
@@ -197,5 +197,70 @@ Posterous.prototype.deleteSite = function deleteSite(id, callback) {
});
};
+//Get 20 random photos from a site
+//allowed keys for `options` parameter are `page` and `since_id`
+Posterous.prototype.getPhotos = function getPhotos(id, options, callback) {
+ this.request('GET', 'sites/' + id + '/photos', options, function(err, result) {
+ if (err) {
+ return callback(err);
+ }
+
+ callback(null, result);
+ });
+};
+
+Posterous.prototype.subscribe = function subscribeTo(id, callback) {
+ this.request('PUT', 'sites/' + id + '/subscribe', null, function(err, result) {
+ if (err) {
+ return callback(err);
+ }
+
+ callback(null, result);
+ });
+};
+
+Posterous.prototype.unsubscribe = function unsubscribeFrom(id, callback) {
+ this.request('PUT', 'sites/' + id + '/unsubscribe', null, function(err, result) {
+ if (err) {
+ return callback(err);
+ }
+
+ callback(null, result);
+ });
+};
+
+Posterous.prototype.setHeader = function setHeader(id, file, callback) {
+ this.request('POST', 'sites/' + id + '/header_image', {file: file}, function(err, result) {
+ if (err) {
+ return callback(err);
+ }
+
+ callback(null, result);
+ });
+};
+
+Posterous.prototype.deleteHeader = function deleteHeader(id, callback) {
+ this.request('DELETE', 'sites/' + id + '/header_image', null, function(err, result) {
+ if (err) {
+ return callback(err);
+ }
+
+ callback(null, result);
+ });
+};
+
+//TODO: Site profile methods
+
+
+Posterous.prototype.getTags = function getTags(id, callback) {
+ this.request('GET', 'sites/' + id + '/tags', null, function(err, result) {
+ if (err) {
+ return callback(err);
+ }
+
+ callback(null, result);
+ });
+};
+
module.exports = Posterous;

0 comments on commit e19533c

Please sign in to comment.