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
73
74
75
76
77
78
79
80
81
82
//! Cover art endpoint handler.
//!
//! <https://api.mangadex.org/swagger.html#/Cover>

mod delete;
mod edit;
mod get;
pub(crate) mod list;
pub(crate) mod upload;

use crate::v5::cover::delete::DeleteCoverBuilder;
use crate::v5::cover::edit::EditCoverBuilder;
use crate::v5::cover::get::GetCoverBuilder;
use crate::v5::cover::list::ListCoverBuilder;
use crate::v5::cover::upload::UploadCoverBuilder;
use crate::HttpClientRef;

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

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

    /// Search a list of cover art.
    ///
    /// <https://api.mangadex.org/swagger.html#/Cover/get-cover>
    pub fn list(&self) -> ListCoverBuilder {
        ListCoverBuilder::default().http_client(self.http_client.clone())
    }

    /// Search a list of cover art.
    ///
    /// <https://api.mangadex.org/swagger.html#/Cover/get-cover>
    ///
    /// This is an alias for the [`Self::list()`] function.
    pub fn search(&self) -> ListCoverBuilder {
        self.list()
    }

    /// View a single cover.
    ///
    /// <https://api.mangadex.org/swagger.html#/Cover/get-cover-id>
    pub fn get(&self) -> GetCoverBuilder {
        GetCoverBuilder::default().http_client(self.http_client.clone())
    }

    /// View a single cover.
    ///
    /// <https://api.mangadex.org/swagger.html#/Cover/get-cover-id>
    ///
    /// This is an alias for [`Self::get()`] to maintain backwards-compatibility.
    pub fn view(&self) -> GetCoverBuilder {
        self.get()
    }

    /// Edit a cover.
    ///
    /// <https://api.mangadex.org/swagger.html#/Cover/edit-cover>
    pub fn edit(&self) -> EditCoverBuilder {
        EditCoverBuilder::default().http_client(self.http_client.clone())
    }

    /// Delete a cover.
    ///
    /// <https://api.mangadex.org/swagger.html#/Cover/delete-cover>
    pub fn delete(&self) -> DeleteCoverBuilder {
        DeleteCoverBuilder::default().http_client(self.http_client.clone())
    }

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