aboutsummaryrefslogtreecommitdiff
path: root/trakt-rs/src/api/users.rs
blob: 6ea4af8d143d11fcbfdd08e24351542cb0423332 (plain) (blame)
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
//! User endpoints
//!
//! <https://trakt.docs.apiary.io/#reference/users>

pub mod settings {
    //! Retrieve Settings
    //!
    //! <https://trakt.docs.apiary.io/#reference/users/settings/retrieve-settings>

    use std::collections::HashMap;

    use smol_str::SmolStr;
    use time::OffsetDateTime;

    #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, Default, trakt_macros::Request)]
    #[trakt(
    response = Response,
    endpoint = "/users/settings",
    auth = Required,
    )]
    pub struct Request;

    #[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, trakt_macros::Response)]
    pub struct Response {
        pub user: FullUser,
        pub account: Account,
        pub connections: Connections,
        pub sharing_text: SharingText,
        pub limits: Limits,
    }

    #[allow(clippy::struct_excessive_bools)]
    #[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize)]
    #[non_exhaustive]
    pub struct FullUser {
        pub username: SmolStr,
        pub private: bool,
        pub name: SmolStr,
        pub vip: bool,
        pub vip_ep: bool,
        pub ids: UserIds,
        #[serde(with = "time::serde::iso8601")]
        pub joined_at: OffsetDateTime,
        pub location: SmolStr,
        pub about: String,
        pub gender: SmolStr,
        pub age: u8,
        pub images: Images,
        pub vip_og: bool,
        pub vip_years: u8,
    }

    #[derive(Debug, Clone, Eq, PartialEq, Hash, serde::Deserialize)]
    #[non_exhaustive]
    pub struct UserIds {
        pub slug: SmolStr,
        pub uuid: String,
    }

    #[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize)]
    pub struct Images {
        pub avatar: Avatar,
        #[serde(flatten)]
        pub extra: HashMap<String, serde_json::Value>,
    }

    #[derive(Debug, Clone, Eq, PartialEq, Hash, serde::Deserialize)]
    #[non_exhaustive]
    pub struct Avatar {
        pub full: String,
    }

    #[derive(Debug, Clone, Eq, PartialEq, Hash, serde::Deserialize)]
    #[non_exhaustive]
    pub struct Account {
        pub timezone: SmolStr,
        pub date_format: SmolStr,
        pub time_24hr: bool,
        pub cover_image: String,
    }

    #[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize)]
    pub struct Connections(HashMap<String, bool>);

    #[derive(Debug, Clone, Eq, PartialEq, Hash, serde::Deserialize)]
    #[non_exhaustive]
    pub struct SharingText {
        pub watching: String,
        pub watched: String,
        pub rated: String,
    }

    #[derive(Debug, Clone, Eq, PartialEq, Hash, serde::Deserialize)]
    #[non_exhaustive]
    pub struct Limits {
        pub list: Limit,
        pub watchlist: Limit,
        pub favorites: Limit,
    }

    #[derive(Debug, Clone, Eq, PartialEq, Hash, serde::Deserialize)]
    pub struct Limit {
        pub count: Option<u32>,
        pub item_count: u32,
    }
}

pub mod follow;