diff options
author | 2021-05-16 13:46:59 -0700 | |
---|---|---|
committer | 2021-05-16 22:17:54 -0700 | |
commit | bb1f98f8e126658a658409fd1b317ae66148cfa6 (patch) | |
tree | ea55d6218ccf21b15a87529c0201f845fc1542ad /src/lib.rs | |
parent | 2abfa7ef1e5ec11de44ec2c59fb0f0980c6e4908 (diff) | |
download | notion-bb1f98f8e126658a658409fd1b317ae66148cfa6.tar.gz notion-bb1f98f8e126658a658409fd1b317ae66148cfa6.tar.zst notion-bb1f98f8e126658a658409fd1b317ae66148cfa6.zip |
refactor
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 32 |
1 files changed, 30 insertions, 2 deletions
@@ -1,5 +1,5 @@ use crate::models::search::{DatabaseQuery, SearchRequest}; -use crate::models::{Database, DatabaseId, ListResponse, Object, Page, Block}; +use crate::models::{Database, DatabaseId, ListResponse, Object, Page, Block, BlockId}; use reqwest::header::{HeaderMap, HeaderValue}; use reqwest::{header, Client, ClientBuilder, RequestBuilder}; use serde::de::DeserializeOwned; @@ -104,7 +104,7 @@ impl NotionApi { .await?) } - pub async fn get_block_children<T: Identifiable<Type = String>>( + pub async fn get_block_children<T: Identifiable<Type = BlockId>>( &self, block_id: T ) -> Result<ListResponse<Block>, NotionApiClientError> { @@ -215,6 +215,34 @@ mod tests { } #[tokio::test] + async fn get_block_children() -> Result<(), Box<dyn std::error::Error>> { + let api = test_client(); + + let search_response = api + .search(NotionSearch::Filter { + value: FilterValue::Page, + property: FilterProperty::Object, + }) + .await?; + + for page in search_response.results() { + let response = api + .get_block_children(page) + .await?; + } + + + // let db = response.results()[0].clone(); + // + // // todo: fix this clone issue + // let db_result = api.get_database(db.clone()).await?; + // + // assert_eq!(db, db_result); + + Ok(()) + } + + #[tokio::test] async fn query_database() -> Result<(), Box<dyn std::error::Error>> { let api = test_client(); |