From 9a084dd397e69dfc941e585574ee426b28772da4 Mon Sep 17 00:00:00 2001 From: Harold Alcala Date: Sat, 11 May 2019 13:14:03 +0800 Subject: [PATCH] Get content child by content id --- lib/confluence.js | 56 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) 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); + }); }; /**