aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Anshul Gupta <ansg191@anshulg.com> 2024-02-19 14:50:21 -0800
committerGravatar Anshul Gupta <ansg191@anshulg.com> 2024-02-20 18:47:15 -0800
commita44dc512448c3960dc2e6a85435bb0caa0a6c13a (patch)
tree7f78f74a580be6aceaacd60a79ff929a2c95a19d
parent10e9c146cf680147be2f4f5ec107178e13800685 (diff)
downloadtrakt-a44dc512448c3960dc2e6a85435bb0caa0a6c13a.tar.gz
trakt-a44dc512448c3960dc2e6a85435bb0caa0a6c13a.tar.zst
trakt-a44dc512448c3960dc2e6a85435bb0caa0a6c13a.zip
feat(api): adds `/users/settings`
-rw-r--r--trakt-rs/src/api.rs1
-rw-r--r--trakt-rs/src/api/users.rs106
2 files changed, 107 insertions, 0 deletions
diff --git a/trakt-rs/src/api.rs b/trakt-rs/src/api.rs
index c5dd980..c0bc9df 100644
--- a/trakt-rs/src/api.rs
+++ b/trakt-rs/src/api.rs
@@ -17,3 +17,4 @@ pub mod movies;
pub mod scrobble;
pub mod search;
pub mod shows;
+pub mod users;
diff --git a/trakt-rs/src/api/users.rs b/trakt-rs/src/api/users.rs
new file mode 100644
index 0000000..42e2a0d
--- /dev/null
+++ b/trakt-rs/src/api/users.rs
@@ -0,0 +1,106 @@
+//! 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,
+ }
+}