mangadex_api/v5/user/
id.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
#[cfg(feature = "custom_list_v2")]
pub mod bookmark;
pub mod follow;
pub mod get;
pub mod list;

use crate::HttpClientRef;
#[cfg(feature = "custom_list_v2")]
use bookmark::BookmarkEndpoint;
use follow::FollowEndpoint;
use get::GetUserBuilder;
use list::ListEndpoint;
use uuid::Uuid;

#[derive(Debug)]
pub struct IdEndpoint {
    http_client: HttpClientRef,
    id: Uuid,
}

impl IdEndpoint {
    pub fn new(http_client: HttpClientRef, id: Uuid) -> Self {
        Self { http_client, id }
    }

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

    #[cfg_attr(
        feature = "custom_list_v2",
        deprecated(since = "3.0.0-alpha.1", note = "use .bookmark() instead")
    )]
    pub fn follow(&self) -> FollowEndpoint {
        FollowEndpoint::new(self.http_client.clone(), self.id)
    }

    cfg_custom_list_v2! {
        pub fn bookmark(&self) -> BookmarkEndpoint {
            BookmarkEndpoint::new(self.http_client.clone(), self.id)
        }
    }

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