diff --git a/src/models/mod.rs b/src/models/mod.rs index c88582e..9bd6d77 100644 --- a/src/models/mod.rs +++ b/src/models/mod.rs @@ -9,6 +9,7 @@ pub mod users; use crate::models::properties::{PropertyConfiguration, PropertyValue}; use crate::models::text::RichText; use crate::Error; +use block::FileOrEmojiObject; use serde::{Deserialize, Serialize}; use std::collections::HashMap; @@ -39,6 +40,7 @@ pub struct Database { pub last_edited_time: DateTime, /// Name of the database as it appears in Notion. pub title: Vec, + pub icon: Option, /// Schema of properties for the database as they appear in Notion. // // key string @@ -180,6 +182,7 @@ pub struct Page { pub last_edited_time: DateTime, /// The archived status of the page. pub archived: bool, + pub icon: Option, pub properties: Properties, pub parent: Parent, } diff --git a/tests/databases.rs b/tests/databases.rs index 75b2c72..ce147a7 100644 --- a/tests/databases.rs +++ b/tests/databases.rs @@ -2,6 +2,7 @@ use test_log::test; mod common; use common::test_client; use rusticnotion::models::{ + block::FileOrEmojiObject, search::{ DatabaseQuery, FilterCondition, FilterProperty, FilterValue, NotionSearch, PropertyCondition, TextCondition, @@ -61,9 +62,16 @@ async fn query_database() -> Result<(), Box> { .expect("Test expected to find at least one database in notion") .clone(); + assert_eq!( + db.icon, + Some(FileOrEmojiObject::Emoji { + emoji: "🪑".to_string(), + }) + ); + let pages = api .query_database( - db, + db.clone(), DatabaseQuery { filter: Some(FilterCondition::Property { property: "Name".to_string(), @@ -77,6 +85,18 @@ async fn query_database() -> Result<(), Box> { .await?; assert_eq!(pages.results().len(), 1); + assert_eq!( + pages.results()[0].icon, + Some(FileOrEmojiObject::Emoji { + emoji: "🌋".to_string(), + }) + ); + + let pages = api.query_database(db, DatabaseQuery::default()).await?; + + for page in pages.results() { + assert!(page.icon.is_some()); + } Ok(()) }