Skip to content

Commit 679488d

Browse files
Add getContentChildByContentId and getContentDescentandByContentId
source: johnpduane#25
1 parent 27f300d commit 679488d

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

lib/confluence.js

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,64 @@ Confluence.prototype.getContentById = function(id, callback){
119119
});
120120
};
121121

122+
/**
123+
* Get stored content child(ren) by content id
124+
*
125+
* @param {string} id
126+
* @param {string} child_type ('page' ...)
127+
* @param {Function} callback
128+
*/
129+
Confluence.prototype.getContentChildByContentId = function(id, child_type, callback) {
130+
if (typeof child_type === "function") {
131+
callback = child_type;
132+
child_type = undefined;
133+
}
134+
135+
request
136+
.get(
137+
this.config.baseUrl +
138+
this.config.apiPath +
139+
"/content/" +
140+
id +
141+
"/child" +
142+
(typeof child_type === "string" ? "/" + child_type : "") +
143+
"?expand=body.storage,version"
144+
)
145+
.auth(this.config.username, this.config.password)
146+
.end(function(err, res) {
147+
processCallback(callback, err, res);
148+
});
149+
};
150+
151+
/**
152+
* Get stored content descendant(s) by content id
153+
*
154+
* @param {string} id
155+
* @param {string} child_type ('page' ...)
156+
* @param {Function} callback
157+
*/
158+
Confluence.prototype.getContentDescendantByContentId = function(id, child_type, callback) {
159+
if (typeof child_type === "function") {
160+
callback = child_type;
161+
child_type = undefined;
162+
}
163+
164+
request
165+
.get(
166+
this.config.baseUrl +
167+
this.config.apiPath +
168+
"/content/" +
169+
id +
170+
"/descendant" +
171+
(typeof child_type === "string" ? "/" + child_type : "") +
172+
"?expand=body.storage,version"
173+
)
174+
.auth(this.config.username, this.config.password)
175+
.end(function(err, res) {
176+
processCallback(callback, err, res);
177+
});
178+
};
179+
122180
/**
123181
* Get stored content for a specific page id with optional custom expanders.
124182
*

0 commit comments

Comments
 (0)