shared/api/endpoints/
pdf.rs

1/// routes for the user pdf library
2pub mod user {
3    use crate::{
4        api::{ApiEndpoint, Method},
5        domain::{
6            pdf::{
7                user::{
8                    UserPdfCreatePath, UserPdfDeletePath, UserPdfGetPath, UserPdfListPath,
9                    UserPdfListResponse, UserPdfResponse, UserPdfUploadPath, UserPdfUploadRequest,
10                    UserPdfUploadResponse,
11                },
12                PdfId,
13            },
14            CreateResponse,
15        },
16        error::EmptyError,
17    };
18
19    /// List pdf files.
20    pub struct List;
21    impl ApiEndpoint for List {
22        type Path = UserPdfListPath;
23        type Req = ();
24        type Res = UserPdfListResponse;
25        type Err = EmptyError;
26        const METHOD: Method = Method::Get;
27    }
28
29    /// Get an pdf file by ID.
30    pub struct Get;
31    impl ApiEndpoint for Get {
32        type Path = UserPdfGetPath;
33        type Req = ();
34        type Res = UserPdfResponse;
35        type Err = EmptyError;
36        const METHOD: Method = Method::Get;
37    }
38
39    /// Create a pdf file.
40    pub struct Create;
41    impl ApiEndpoint for Create {
42        type Path = UserPdfCreatePath;
43        type Req = ();
44        type Res = CreateResponse<PdfId>;
45        type Err = EmptyError;
46        const METHOD: Method = Method::Post;
47    }
48
49    /// Upload a pdf file. Returns a pre-signed URL for upload to Google Cloud Storage.
50    ///
51    /// Notes:
52    /// * can be used to update the raw data associated with the pdf file.
53    pub struct Upload;
54    impl ApiEndpoint for Upload {
55        type Path = UserPdfUploadPath;
56        // raw bytes
57        type Req = UserPdfUploadRequest;
58        type Res = UserPdfUploadResponse;
59        type Err = EmptyError;
60        const METHOD: Method = Method::Put;
61    }
62
63    /// Delete a pdf file.
64    pub struct Delete;
65    impl ApiEndpoint for Delete {
66        type Path = UserPdfDeletePath;
67        type Req = ();
68        type Res = ();
69        type Err = EmptyError;
70        const METHOD: Method = Method::Delete;
71    }
72}