diff --git a/src/api_core/client.rs b/src/api_core/client.rs index 32260bb..6900bf8 100644 --- a/src/api_core/client.rs +++ b/src/api_core/client.rs @@ -12,7 +12,9 @@ use crate::api_core::adding_urls::{ GetUrlFilesResponse, GetUrlInfo, GetUrlInfoResponse, }; use crate::api_core::common::{FileIdentifier, FileMetadataInfo, FileRecord}; -use crate::api_core::managing_pages::{GetPage, GetPagesResponse}; +use crate::api_core::managing_pages::{ + GetPageInfo, GetPageInfoResponse, GetPages, GetPagesResponse, +}; use crate::api_core::searching_and_fetching_files::{ FileMetadata, FileMetadataResponse, FileSearchLocation, GetFile, SearchFiles, SearchFilesResponse, @@ -311,6 +313,12 @@ impl Client { /// Returns all pages of the client pub async fn get_pages(&self) -> Result { - self.get_and_parse::(&()).await + self.get_and_parse::(&()).await + } + + /// Returns information about a single page + pub async fn get_page_info>(&self, page_key: S) -> Result { + self.get_and_parse::(&[("page_key", page_key.as_ref())]) + .await } } diff --git a/src/api_core/common.rs b/src/api_core/common.rs index 4af9965..20c2c6c 100644 --- a/src/api_core/common.rs +++ b/src/api_core/common.rs @@ -56,7 +56,7 @@ pub struct PageInformation { pub page_key: String, pub page_type: u32, #[serde(alias = "focused")] - pub selected: bool, + pub selected: Option, #[serde(default = "Vec::new")] pub pages: Vec, } diff --git a/src/api_core/managing_pages.rs b/src/api_core/managing_pages.rs index e553a60..1e96361 100644 --- a/src/api_core/managing_pages.rs +++ b/src/api_core/managing_pages.rs @@ -7,9 +7,9 @@ pub struct GetPagesResponse { pub pages: PageInformation, } -pub struct GetPage; +pub struct GetPages; -impl Endpoint for GetPage { +impl Endpoint for GetPages { type Request = (); type Response = GetPagesResponse; @@ -17,3 +17,19 @@ impl Endpoint for GetPage { String::from("manage_pages/get_pages") } } + +#[derive(Clone, Debug, Deserialize)] +pub struct GetPageInfoResponse { + pub page_info: PageInformation, +} + +pub struct GetPageInfo; + +impl Endpoint for GetPageInfo { + type Request = (); + type Response = GetPageInfoResponse; + + fn path() -> String { + String::from("manage_pages/get_page_info") + } +} diff --git a/tests/client/test_managing_pages.rs b/tests/client/test_managing_pages.rs index 9d12bdf..50c24c3 100644 --- a/tests/client/test_managing_pages.rs +++ b/tests/client/test_managing_pages.rs @@ -5,3 +5,12 @@ async fn it_returns_all_pages() { let client = common::get_client(); client.get_pages().await.unwrap(); } + +#[tokio::test] +async fn it_returns_page_info() { + let client = common::get_client(); + let result = client + .get_page_info("0c33d6599c22d5ec12a57b79d8c5a528ebdab7a8c2b462e6d76e2d0512e917fd") + .await; + assert!(result.is_err()); // page does not exist +}