aboutsummaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
authorGravatar Brett Spradling <bspradling@godaddy.com> 2021-05-16 13:46:59 -0700
committerGravatar Brett Spradling <bspradling@godaddy.com> 2021-05-16 22:17:54 -0700
commitbb1f98f8e126658a658409fd1b317ae66148cfa6 (patch)
treeea55d6218ccf21b15a87529c0201f845fc1542ad /src/lib.rs
parent2abfa7ef1e5ec11de44ec2c59fb0f0980c6e4908 (diff)
downloadnotion-bb1f98f8e126658a658409fd1b317ae66148cfa6.tar.gz
notion-bb1f98f8e126658a658409fd1b317ae66148cfa6.tar.zst
notion-bb1f98f8e126658a658409fd1b317ae66148cfa6.zip
refactor
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs32
1 files changed, 30 insertions, 2 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 0f9068f..5d9919a 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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();