Skip to content

Commit

Permalink
Merge pull request #11 from tigsikram/add-getDescendents()
Browse files Browse the repository at this point in the history
add get_descendents()
  • Loading branch information
Nercury authored May 4, 2023
2 parents 6cc4e82 + 9e4371e commit 88d4c53
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,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<Vec<PageSummary>> {
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
Expand Down

0 comments on commit 88d4c53

Please sign in to comment.