Add client endpoint to focus a page

Signed-off-by: trivernis <trivernis@protonmail.com>
pull/2/head
trivernis 3 years ago
parent 9854927938
commit 92ff53e163
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

@ -13,7 +13,7 @@ use crate::api_core::adding_urls::{
}; };
use crate::api_core::common::{FileIdentifier, FileMetadataInfo, FileRecord}; use crate::api_core::common::{FileIdentifier, FileMetadataInfo, FileRecord};
use crate::api_core::managing_pages::{ use crate::api_core::managing_pages::{
GetPageInfo, GetPageInfoResponse, GetPages, GetPagesResponse, FocusPage, FocusPageRequest, GetPageInfo, GetPageInfoResponse, GetPages, GetPagesResponse,
}; };
use crate::api_core::searching_and_fetching_files::{ use crate::api_core::searching_and_fetching_files::{
FileMetadata, FileMetadataResponse, FileSearchLocation, GetFile, SearchFiles, FileMetadata, FileMetadataResponse, FileSearchLocation, GetFile, SearchFiles,
@ -321,4 +321,14 @@ impl Client {
self.get_and_parse::<GetPageInfo, [(&str, &str)]>(&[("page_key", page_key.as_ref())]) self.get_and_parse::<GetPageInfo, [(&str, &str)]>(&[("page_key", page_key.as_ref())])
.await .await
} }
/// Focuses a page in the client
pub async fn focus_page<S: ToString>(&self, page_key: S) -> Result<()> {
self.post::<FocusPage>(FocusPageRequest {
page_key: page_key.to_string(),
})
.await?;
Ok(())
}
} }

@ -33,3 +33,19 @@ impl Endpoint for GetPageInfo {
String::from("manage_pages/get_page_info") String::from("manage_pages/get_page_info")
} }
} }
#[derive(Clone, Debug, Serialize)]
pub struct FocusPageRequest {
pub page_key: String,
}
pub struct FocusPage;
impl Endpoint for FocusPage {
type Request = FocusPageRequest;
type Response = ();
fn path() -> String {
String::from("manage_pages/focus_page")
}
}

@ -14,3 +14,13 @@ async fn it_returns_page_info() {
.await; .await;
assert!(result.is_err()); // page does not exist assert!(result.is_err()); // page does not exist
} }
#[tokio::test]
async fn it_focuses_pages() {
let client = common::get_client();
let result = client
.focus_page("0c33d6599c22d5ec12a57b79d8c5a528ebdab7a8c2b462e6d76e2d0512e917fd")
.await;
assert!(result.is_err()); // page does not exist
}

Loading…
Cancel
Save