shared/api/endpoints/
pdf.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/// routes for the user pdf library
pub mod user {
    use crate::{
        api::{ApiEndpoint, Method},
        domain::{
            pdf::{
                user::{
                    UserPdfCreatePath, UserPdfDeletePath, UserPdfGetPath, UserPdfListPath,
                    UserPdfListResponse, UserPdfResponse, UserPdfUploadPath, UserPdfUploadRequest,
                    UserPdfUploadResponse,
                },
                PdfId,
            },
            CreateResponse,
        },
        error::EmptyError,
    };

    /// List pdf files.
    pub struct List;
    impl ApiEndpoint for List {
        type Path = UserPdfListPath;
        type Req = ();
        type Res = UserPdfListResponse;
        type Err = EmptyError;
        const METHOD: Method = Method::Get;
    }

    /// Get an pdf file by ID.
    pub struct Get;
    impl ApiEndpoint for Get {
        type Path = UserPdfGetPath;
        type Req = ();
        type Res = UserPdfResponse;
        type Err = EmptyError;
        const METHOD: Method = Method::Get;
    }

    /// Create a pdf file.
    pub struct Create;
    impl ApiEndpoint for Create {
        type Path = UserPdfCreatePath;
        type Req = ();
        type Res = CreateResponse<PdfId>;
        type Err = EmptyError;
        const METHOD: Method = Method::Post;
    }

    /// Upload a pdf file. Returns a pre-signed URL for upload to Google Cloud Storage.
    ///
    /// Notes:
    /// * can be used to update the raw data associated with the pdf file.
    pub struct Upload;
    impl ApiEndpoint for Upload {
        type Path = UserPdfUploadPath;
        // raw bytes
        type Req = UserPdfUploadRequest;
        type Res = UserPdfUploadResponse;
        type Err = EmptyError;
        const METHOD: Method = Method::Put;
    }

    /// Delete a pdf file.
    pub struct Delete;
    impl ApiEndpoint for Delete {
        type Path = UserPdfDeletePath;
        type Req = ();
        type Res = ();
        type Err = EmptyError;
        const METHOD: Method = Method::Delete;
    }
}