mangadex_api/v5/
upload.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
//! Upload endpoint handler.
//!
//! <https://api.mangadex.org/docs/swagger.html#/Upload>

use uuid::Uuid;

use crate::v5::cover::manga_id::post::UploadCoverBuilder;

use crate::HttpClientRef;

pub mod begin;
pub mod check_approval_required;
pub mod get;
pub mod upload_session_id;

use self::begin::BeginEndpoint;
use self::check_approval_required::CheckApprovalRequiredEndpoint;
use self::get::GetUploadSessionBuilder;
use self::upload_session_id::UploadSessionIdEndpoint;

/// Upload endpoint handler builder.
#[derive(Debug)]
pub struct UploadBuilder {
    http_client: HttpClientRef,
}

impl UploadBuilder {
    #[doc(hidden)]
    pub(crate) fn new(http_client: HttpClientRef) -> Self {
        Self { http_client }
    }

    /// Upload a manga cover image.
    ///
    /// <https://api.mangadex.org/swagger.html#/Upload/upload-cover>
    pub fn cover(&self, manga_id: Uuid) -> UploadCoverBuilder {
        UploadCoverBuilder::default()
            .manga_id(manga_id)
            .http_client(self.http_client.clone())
    }

    pub fn get(&self) -> GetUploadSessionBuilder {
        GetUploadSessionBuilder::default().http_client(self.http_client.clone())
    }

    pub fn begin(&self) -> BeginEndpoint {
        BeginEndpoint::new(self.http_client.clone())
    }

    pub fn upload_session_id(&self, upload_session_id: Uuid) -> UploadSessionIdEndpoint {
        UploadSessionIdEndpoint::new(self.http_client.clone(), upload_session_id)
    }
    pub fn check_approval_required(&self) -> CheckApprovalRequiredEndpoint {
        CheckApprovalRequiredEndpoint::new(self.http_client.clone())
    }
}