From 9e4371e8fc720a8370258f5a8aa8946aa15d4339 Mon Sep 17 00:00:00 2001 From: Mark Weiler Date: Wed, 5 Apr 2023 10:45:47 +0200 Subject: [PATCH] add get_descendents() --- src/lib.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index aff410b..8e186b7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -376,6 +376,28 @@ impl Session { Ok(summaries) } + /** + * getDescendents + * returns all the descendants of this page (children, children's children etc). + */ + pub fn get_descendents(&self, page_id: i64) -> Result> { + let response = self.call( + Method::new("getDescendents") + .with(Element::node("token").with_text(&self.token)) + .with(Element::node("pageId").with_text(page_id.to_string())) + )?; + + let element = response.body.descend(&["getDescendentsReturn"])?; + + let mut summaries = vec![]; + + for element in element.children { + summaries.push(PageSummary::from_element(element)?); + } + + Ok(summaries) + } + /// Call a custom method on this session. /// /// ## Usage