paperless_rs/endpoint/
document_types.rs1use reqwest::Method;
2use serde::{Deserialize, Serialize};
3
4use crate::utils::pagination::Response;
5use crate::PaperlessClient;
6
7#[derive(Serialize, Deserialize, Debug)]
8pub struct DocumentType {
9 pub id: u64,
10 pub slug: String,
11 pub name: String,
12 #[serde(rename = "match")]
13 pub match_type: String,
14 pub matching_algorithm: u64,
15 pub is_insensitive: bool,
16 pub document_count: u64,
17 pub owner: u64,
18 pub user_can_change: bool,
19}
20
21impl PaperlessClient {
22 pub async fn fetch_document_types(
23 &self,
24 ) -> Result<Response<DocumentType>, Box<dyn std::error::Error>> {
25 let url = format!("{}/document_types/", self.base_url);
26
27 let request_builder = self.prepare_endpoint(Method::GET, url).await?;
28 self.call_endpoint(request_builder).await
29 }
30
31 pub async fn fetch_document_type(
32 &self,
33 document_type_id: u64,
34 ) -> Result<DocumentType, Box<dyn std::error::Error>> {
35 let url = format!("{}/document_types/{}/", self.base_url, document_type_id);
36
37 let request_builder = self.prepare_endpoint(Method::GET, url).await?;
38 self.call_endpoint(request_builder).await
39 }
40}