notion_api_rs/notion/
page.rs1use super::client::Client;
2use super::common::File;
3use anyhow::Result;
4use serde::{Deserialize, Serialize};
5
6#[derive(Debug, Serialize, Deserialize)]
8pub struct Page {
9 pub object: String,
10 pub id: String,
11 pub created_time: String,
12 pub last_edited_time: String,
13 pub archived: bool,
14 pub icon: Option<Icon>,
15 pub cover: Option<File>,
16 pub url: String,
17 pub parent: Option<String>,
18}
19
20#[derive(Debug, Serialize, Deserialize)]
21pub struct Parent {
22 pub parent_type: String,
23 pub database_id: Option<String>,
24 pub page_id: Option<String>,
25 pub workspace: Option<String>
26}
27
28#[derive(Debug, Serialize, Deserialize)]
29pub struct Icon {
30 #[serde(rename = "type")]
31 pub icon_type: String,
32 pub file: Option<File>,
33 pub emoji: Option<String>,
34}
35
36impl Client {
37 pub async fn get_page(&self, id: String) -> Result<Page> {
38 let url = format!("{}/pages/{}", self.base_api, id);
39 let resp = self.client.get(&url).send().await?;
40 let page = resp.json::<Page>().await?;
41 Ok(page)
42 }
43}