node-pinboard
Version:
A Node.js wrapper for the Pinboard API.
104 lines • 3.81 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var get_1 = require("./get");
function pinboardMethod(endpoint, token) {
return function (options, callback) {
var qs = Object.assign({},
// eslint-disable-next-line @typescript-eslint/camelcase
{ auth_token: token, format: 'json' }, options);
var params = {
endpoint: endpoint,
qs: qs
};
return get_1.default(params, callback);
};
}
var Pinboard = /** @class */ (function () {
/**
* Uses token available on [settings/password](https://pinboard.in/settings/password)
*/
function Pinboard(token) {
this.token = token;
/**
* Returns The most recent time a bookmark was added, updated or deleted.
*/
this.update = pinboardMethod('posts/update', this.token);
/**
* Add a bookmark.
*/
this.add = pinboardMethod('posts/add', this.token);
/**
* Returns one or more posts on a single day matching the arguments.
* If no date or url is given, date of most recent bookmark will be used.
*/
this.get = pinboardMethod('posts/get', this.token);
/**
* Returns a list of dates with the number of posts at each date.
*/
this.dates = pinboardMethod('posts/dates', this.token);
/**
* Returns a list of the user's most recent posts, filtered by tag.
*/
this.recent = pinboardMethod('posts/recent', this.token);
/**
* Returns all bookmarks in the user's account.
*/
this.all = pinboardMethod('posts/all', this.token);
/**
* Returns a full list of the user's tags along with the number of times they were used.
*/
this.getTags = pinboardMethod('tags/get', this.token);
/**
* Rename an tag, or fold it in to an existing tag
*/
this.renameTag = pinboardMethod('tags/rename', this.token);
/**
* Returns the user's secret RSS key (for viewing private feeds)
*/
this.userSecret = pinboardMethod('user/secret', this.token);
/**
* Returns the user's API token (for making API calls without a password)
*/
this.api_token = pinboardMethod('user/api_token', this.token);
}
/**
* Delete a bookmark.
*/
Pinboard.prototype.delete = function (url, cb) {
return pinboardMethod('posts/delete', this.token)({ url: url }, cb);
};
/**
* Returns a list of popular tags and recommended tags for a given URL.
* Popular tags are tags used site-wide for the url; recommended tags are drawn from the user's own tags.
*/
Pinboard.prototype.suggest = function (url, cb) {
return pinboardMethod('posts/suggest', this.token)({ url: url }, cb);
};
/**
* Delete an existing tag.
*/
Pinboard.prototype.delTag = function (tag, cb) {
return pinboardMethod('tags/delete', this.token)({ tag: tag }, cb);
};
/**
* Returns a list of the user's notes
*/
Pinboard.prototype.listNotes = function (cb) {
return pinboardMethod('notes/list', this.token)({}, cb);
};
/**
* Returns an individual user note. The hash property is a 20 character long sha1 hash of the note text.
*/
Pinboard.prototype.getNote = function (id, cb) {
var endpoint = "notes/" + id;
var params = {
endpoint: endpoint,
// eslint-disable-next-line @typescript-eslint/camelcase
qs: { auth_token: this.token, format: 'json' }
};
return get_1.default(params, cb);
};
return Pinboard;
}());
exports.default = Pinboard;
//# sourceMappingURL=index.js.map