mangadex_api/v5/
user.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//! User endpoint handler.
//!
//! <https://api.mangadex.org/docs/swagger.html#/User>

cfg_custom_list_v2! {
    pub mod bookmarks;
}

#[cfg(feature = "legacy-user-delete")]
pub mod delete;
pub mod follows;
pub mod get;
pub mod history;
pub mod id;
pub mod list;
pub mod me;
cfg_custom_list_v2! {
    pub mod subscription;
}

use crate::HttpClientRef;
use uuid::Uuid;

#[cfg(feature = "custom_list_v2")]
use bookmarks::BookmarksEndpoint;
#[cfg(feature = "legacy-user-delete")]
use delete::DeleteEndpoint;
use follows::FollowsEndpoint;
use get::ListUserBuilder;
use history::HistoryEndpoint;
use id::IdEndpoint;
use list::ListEndpoint;
use me::MeEndpoint;
#[cfg(feature = "custom_list_v2")]
use subscription::SubscriptionEndpoint;

#[derive(Debug)]
pub struct UserBuilder {
    http_client: HttpClientRef,
}

impl UserBuilder {
    pub fn new(http_client: HttpClientRef) -> Self {
        Self { http_client }
    }
    cfg_custom_list_v2! {
        pub fn bookmarks(&self) -> BookmarksEndpoint {
            BookmarksEndpoint::new(self.http_client.clone())
        }
    }

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

    #[cfg(feature = "legacy-user-delete")]
    pub fn delete(&self) -> DeleteEndpoint {
        DeleteEndpoint::new(self.http_client.clone())
    }

    pub fn follows(&self) -> FollowsEndpoint {
        FollowsEndpoint::new(self.http_client.clone())
    }

    pub fn history(&self) -> HistoryEndpoint {
        HistoryEndpoint::new(self.http_client.clone())
    }

    pub fn id(&self, id: Uuid) -> IdEndpoint {
        IdEndpoint::new(self.http_client.clone(), id)
    }

    pub fn list(&self) -> ListEndpoint {
        ListEndpoint::new(self.http_client.clone())
    }

    pub fn me(&self) -> MeEndpoint {
        MeEndpoint::new(self.http_client.clone())
    }

    cfg_custom_list_v2! {
        pub fn subscription(&self) -> SubscriptionEndpoint {
            SubscriptionEndpoint::new(self.http_client.clone())
        }
    }
}