Skip to main content

mangadex_api/v5/
user.rs

1//! User endpoint handler.
2//!
3//! <https://api.mangadex.org/docs/swagger.html#/User>
4
5cfg_custom_list_v2! {
6    pub mod bookmarks;
7}
8
9pub mod follows;
10pub mod get;
11pub mod history;
12pub mod id;
13pub mod list;
14pub mod me;
15cfg_custom_list_v2! {
16    pub mod subscription;
17}
18
19use crate::HttpClientRef;
20use uuid::Uuid;
21
22#[cfg(feature = "custom_list_v2")]
23use bookmarks::BookmarksEndpoint;
24use follows::FollowsEndpoint;
25use get::ListUserBuilder;
26use history::HistoryEndpoint;
27use id::IdEndpoint;
28use list::ListEndpoint;
29use me::MeEndpoint;
30#[cfg(feature = "custom_list_v2")]
31use subscription::SubscriptionEndpoint;
32
33#[derive(Debug)]
34pub struct UserBuilder {
35    http_client: HttpClientRef,
36}
37
38impl UserBuilder {
39    pub fn new(http_client: HttpClientRef) -> Self {
40        Self { http_client }
41    }
42    cfg_custom_list_v2! {
43        pub fn bookmarks(&self) -> BookmarksEndpoint {
44            BookmarksEndpoint::new(self.http_client.clone())
45        }
46    }
47
48    pub fn get(&self) -> ListUserBuilder {
49        ListUserBuilder::default().http_client(self.http_client.clone())
50    }
51
52    pub fn follows(&self) -> FollowsEndpoint {
53        FollowsEndpoint::new(self.http_client.clone())
54    }
55
56    pub fn history(&self) -> HistoryEndpoint {
57        HistoryEndpoint::new(self.http_client.clone())
58    }
59
60    pub fn id(&self, id: Uuid) -> IdEndpoint {
61        IdEndpoint::new(self.http_client.clone(), id)
62    }
63
64    pub fn list(&self) -> ListEndpoint {
65        ListEndpoint::new(self.http_client.clone())
66    }
67
68    pub fn me(&self) -> MeEndpoint {
69        MeEndpoint::new(self.http_client.clone())
70    }
71
72    cfg_custom_list_v2! {
73        pub fn subscription(&self) -> SubscriptionEndpoint {
74            SubscriptionEndpoint::new(self.http_client.clone())
75        }
76    }
77}