Add client endpoint to get all pages

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

@ -12,6 +12,7 @@ use crate::api_core::adding_urls::{
GetUrlFilesResponse, GetUrlInfo, GetUrlInfoResponse, GetUrlFilesResponse, GetUrlInfo, GetUrlInfoResponse,
}; };
use crate::api_core::common::{FileIdentifier, FileMetadataInfo, FileRecord}; use crate::api_core::common::{FileIdentifier, FileMetadataInfo, FileRecord};
use crate::api_core::managing_pages::{GetPage, 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,
SearchFilesResponse, SearchFilesResponse,
@ -307,4 +308,9 @@ impl Client {
Ok(()) Ok(())
} }
/// Returns all pages of the client
pub async fn get_pages(&self) -> Result<GetPagesResponse> {
self.get_and_parse::<GetPage, ()>(&()).await
}
} }

@ -49,3 +49,14 @@ pub struct FileRecord {
pub bytes: Vec<u8>, pub bytes: Vec<u8>,
pub mime_type: String, pub mime_type: String,
} }
#[derive(Clone, Debug, Deserialize)]
pub struct PageInformation {
pub name: String,
pub page_key: String,
pub page_type: u32,
#[serde(alias = "focused")]
pub selected: bool,
#[serde(default = "Vec::new")]
pub pages: Vec<PageInformation>,
}

@ -0,0 +1,19 @@
use crate::api_core::common::PageInformation;
use crate::api_core::Endpoint;
#[derive(Clone, Debug, Deserialize)]
pub struct GetPagesResponse {
/// The top level notebook page
pub pages: PageInformation,
}
pub struct GetPage;
impl Endpoint for GetPage {
type Request = ();
type Response = GetPagesResponse;
fn path() -> String {
String::from("manage_pages/get_pages")
}
}

@ -7,6 +7,7 @@ pub mod adding_tags;
pub mod adding_urls; pub mod adding_urls;
pub mod client; pub mod client;
pub mod common; pub mod common;
pub mod managing_pages;
pub mod searching_and_fetching_files; pub mod searching_and_fetching_files;
pub(crate) trait Endpoint { pub(crate) trait Endpoint {

@ -2,4 +2,5 @@ mod test_access_management;
mod test_adding_files; mod test_adding_files;
mod test_adding_tags; mod test_adding_tags;
mod test_adding_urls; mod test_adding_urls;
mod test_managing_pages;
mod test_searching_and_fetching_files; mod test_searching_and_fetching_files;

@ -0,0 +1,7 @@
use super::super::common;
#[tokio::test]
async fn it_returns_all_pages() {
let client = common::get_client();
client.get_pages().await.unwrap();
}
Loading…
Cancel
Save