diff --git a/lib/confluence.js b/lib/confluence.js index 1590f95..8b72a3c 100644 --- a/lib/confluence.js +++ b/lib/confluence.js @@ -117,6 +117,62 @@ Confluence.prototype.getContentById = function(id, callback){ .end(function(err, res){ processCallback(callback, err, res); }); +/** + * Get stored content child(ren) by content id + * + * @param {string} id + * @param {string} child_type ('page' ...) + * @param {Function} callback + */ +Confluence.prototype.getContentChildByContentId = function(id, child_type, callback) { + if (typeof child_type === "function") { + callback = child_type; + child_type = undefined; + } + + request + .get( + this.config.baseUrl + + this.config.apiPath + + "/content/" + + id + + "/child" + + (typeof child_type === "string" ? "/" + child_type : "") + + "?expand=body.storage,version" + ) + .auth(this.config.username, this.config.password) + .end(function(err, res) { + processCallback(callback, err, res); + }); +}; + +/** + * Get stored content descendant(s) by content id + * + * @param {string} id + * @param {string} child_type ('page' ...) + * @param {Function} callback + */ +Confluence.prototype.getContentDescendantByContentId = function(id, child_type, callback) { + if (typeof child_type === "function") { + callback = child_type; + child_type = undefined; + } + + request + .get( + this.config.baseUrl + + this.config.apiPath + + "/content/" + + id + + "/descendant" + + (typeof child_type === "string" ? "/" + child_type : "") + + "?expand=body.storage,version" + ) + .auth(this.config.username, this.config.password) + .end(function(err, res) { + processCallback(callback, err, res); + }); }; /**