@stackend/api
Version:
JS bindings to api.stackend.com
130 lines • 4.16 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.remove = exports.edit = exports.list = exports.getByReferenceId = exports.get = exports.COMPONENT_NAME = exports.COMPONENT_CLASS = exports.Insertion = exports.References = void 0;
var api_1 = require("../api");
/**
* Xcap category api constants and methods.
*
* @since 3 apr 2017
*/
exports.References = {
BLOGEDITOR: 'BlogEditor'
};
/**
* Category insertion points.
*/
var Insertion;
(function (Insertion) {
Insertion["FIRST"] = "FIRST";
Insertion["LAST"] = "LAST";
Insertion["WITH_ORDER"] = "WITH_ORDER";
Insertion["BEFORE_REFERENCE_ID"] = "BEFORE_REFERENCE_ID";
Insertion["AFTER_REFERENCE_ID"] = "AFTER_REFERENCE_ID";
Insertion["MOVE_UP"] = "MOVE_UP";
Insertion["MOVE_DOWN"] = "MOVE_DOWN";
})(Insertion = exports.Insertion || (exports.Insertion = {}));
/**
* Component class (used to look up privileges, etc)
*/
exports.COMPONENT_CLASS = 'net.josh.community.category.CategoryManager';
/**
* Component class
*/
exports.COMPONENT_NAME = 'category';
/**
* Get a category and its branch of categories up to and including the specified category.
*
* @param context {string} Context name, for example "news"
* @param categoryId {number} Category id
* @param permaLink {string} Category permalink, for example "sport/football"
*/
function get(_a) {
var context = _a.context, categoryId = _a.categoryId, permaLink = _a.permaLink;
if (typeof categoryId === 'undefined' && typeof permaLink === 'undefined') {
throw Error('categoryId or permaLink must be specified');
}
return (0, api_1.getJson)({
url: '/category/get',
parameters: arguments,
context: context,
componentName: exports.COMPONENT_NAME
});
}
exports.get = get;
/**
* List all categories referenced by an object.
*
* @param context {string} Context name, for example "news"
* @param referenceId {number} Id of referencing object
*/
function getByReferenceId(_a) {
var context = _a.context, referenceId = _a.referenceId;
return (0, api_1.getJson)({
url: '/category/get-by-reference-id',
parameters: arguments,
context: context,
componentName: exports.COMPONENT_NAME
});
}
exports.getByReferenceId = getByReferenceId;
/**
* List all subcategories of a specified category.
*
* If no category is specified, the root categories are listed.
*
* @param context {string} Context name, for example "news"
* @param categoryId {number} Category id (optional)
* @param permaLink {string} Category permalink, for example "sport/football" (optional)
*/
function list(_a) {
var context = _a.context, categoryId = _a.categoryId, permaLink = _a.permaLink;
return (0, api_1.getJson)({
url: '/category/list',
parameters: arguments,
context: context,
componentName: exports.COMPONENT_NAME
});
}
exports.list = list;
/**
* Edit/create a category.
*
* Requires CMS admin.
*
* @param context {string} Context name, for example "news"
* @param categoryId {number} Category id (optional)
* @param name {string}
* @param description {string}
* @param parentCategoryId {number} Id of parent category (optional)
* @param sortOrder {number} Sort order (optional)
* @returns {Promise}
*/
function edit(_a) {
var context = _a.context, categoryId = _a.categoryId, name = _a.name, description = _a.description, parentCategoryId = _a.parentCategoryId, sortOrder = _a.sortOrder;
return (0, api_1.post)({
url: '/category/edit',
parameters: arguments,
context: context,
componentName: exports.COMPONENT_NAME
});
}
exports.edit = edit;
/**
* Remove a category.
*
* Requires CMS admin.
*
* @param context {string} Context name, for example "news"
* @param id {number} Category id (optional)
*/
function remove(_a) {
var context = _a.context, id = _a.id;
return (0, api_1.post)({
url: '/category/remove',
parameters: arguments,
context: context,
componentName: exports.COMPONENT_NAME
});
}
exports.remove = remove;
//# sourceMappingURL=index.js.map