From 92ff53e163b95067ee18893bf0226a73862e679a Mon Sep 17 00:00:00 2001 From: trivernis Date: Sun, 18 Jul 2021 17:05:25 +0200 Subject: [PATCH] Add client endpoint to focus a page Signed-off-by: trivernis --- src/api_core/client.rs | 12 +++++++++++- src/api_core/managing_pages.rs | 16 ++++++++++++++++ tests/client/test_managing_pages.rs | 10 ++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/api_core/client.rs b/src/api_core/client.rs index 6900bf8..13cd91d 100644 --- a/src/api_core/client.rs +++ b/src/api_core/client.rs @@ -13,7 +13,7 @@ use crate::api_core::adding_urls::{ }; use crate::api_core::common::{FileIdentifier, FileMetadataInfo, FileRecord}; use crate::api_core::managing_pages::{ - GetPageInfo, GetPageInfoResponse, GetPages, GetPagesResponse, + FocusPage, FocusPageRequest, GetPageInfo, GetPageInfoResponse, GetPages, GetPagesResponse, }; use crate::api_core::searching_and_fetching_files::{ FileMetadata, FileMetadataResponse, FileSearchLocation, GetFile, SearchFiles, @@ -321,4 +321,14 @@ impl Client { self.get_and_parse::(&[("page_key", page_key.as_ref())]) .await } + + /// Focuses a page in the client + pub async fn focus_page(&self, page_key: S) -> Result<()> { + self.post::(FocusPageRequest { + page_key: page_key.to_string(), + }) + .await?; + + Ok(()) + } } diff --git a/src/api_core/managing_pages.rs b/src/api_core/managing_pages.rs index 1e96361..49786e0 100644 --- a/src/api_core/managing_pages.rs +++ b/src/api_core/managing_pages.rs @@ -33,3 +33,19 @@ impl Endpoint for GetPageInfo { 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") + } +} diff --git a/tests/client/test_managing_pages.rs b/tests/client/test_managing_pages.rs index 50c24c3..c787f9b 100644 --- a/tests/client/test_managing_pages.rs +++ b/tests/client/test_managing_pages.rs @@ -14,3 +14,13 @@ async fn it_returns_page_info() { .await; 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 +}