danbooru
Version:
danbooru api wrapper
102 lines (82 loc) • 3.82 kB
JavaScript
;
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var booru = require('../booru');
module.exports = function (_booru) {
_inherits(_class, _booru);
function _class() {
_classCallCheck(this, _class);
return _possibleConstructorReturn(this, (_class.__proto__ || Object.getPrototypeOf(_class)).apply(this, arguments));
}
_createClass(_class, [{
key: 'posts',
/**
* `posts#index` or `posts#show`
*
* Get a list of posts or a single post
*
* @param {Object | *} [paramsOrId] Listing params or show id
* @returns {Promise} Resolves to a data array or object
*/
value: function posts() {
var paramsOrId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
if (new Object(paramsOrId) === paramsOrId) return this.get('/posts', paramsOrId);
return this.get('/posts/' + paramsOrId);
}
/**
* `posts#update`
*
* Update a post's data
*
* @param {*} id Post id
* @param {Object} post Post params
* @returns {Promise} Resolves to server response
*/
}, {
key: 'posts_update',
value: function posts_update(id, post) {
return this.put('/posts/' + id, { post: post });
}
/**
* `posts#revert`
*
* Revert a post to a previous version
*
* @param {*} id Post id
* @param {*} version_id Version id
* @returns {Promise} Resolves to server response
*/
}, {
key: 'posts_revert',
value: function posts_revert(id, version_id) {
return this.put('/posts/' + id + '/revert', { version_id: version_id });
}
/**
* `posts#copy_notes`
*
* @param {*} id Post id
* @param {*} other_post_id Other post id
* @returns {Promise} Resolves to server response
*/
}, {
key: 'posts_copyNotes',
value: function posts_copyNotes(id, other_post_id) {
return this.put('/posts/' + id + '/copy_notes', { other_post_id: other_post_id });
}
/**
* `posts#mark_as_translated`
*
* @param {*} id Post id
* @param {Object} post Translation information
* @returns {Promise} Resolves to server response
*/
}, {
key: 'posts_markAsTranslated',
value: function posts_markAsTranslated(id, post) {
return this.put('/posts/' + id + '/mark_as_translated', { post: post });
}
}]);
return _class;
}(booru);