Skip to main content

roblox_api/api/account_information/
v1.rs

1use serde::{Deserialize, Serialize};
2
3use crate::{DateTime, Gender, endpoint};
4
5pub const URL: &str = "https://accountinformation.roblox.com/v1";
6
7#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
8#[serde(rename_all = "camelCase")]
9pub struct RobloxBadge {
10    pub id: u8,
11    pub name: String,
12    pub description: String,
13    pub image_url: String,
14}
15
16#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
17#[serde(rename_all = "camelCase")]
18pub struct PromotionChannels {
19    pub promotion_channels_visibility_privacy: String,
20    pub facebook: Option<String>,
21    pub twitter: Option<String>,
22    pub youtube: Option<String>,
23    pub twitch: Option<String>,
24}
25
26#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
27#[serde(rename_all = "camelCase")]
28pub struct Metadata {
29    #[serde(rename = "isAllowedNotificationsEndpointDisabled")]
30    pub is_allowed_notifications_endpoint_disabled: bool,
31    #[serde(rename = "isAccountSettingsPolicyEnabled")]
32    pub is_account_settings_policy_enabled: bool,
33    #[serde(rename = "isPhoneNumberEnabled")]
34    pub is_phone_number_enabled: bool,
35    #[serde(rename = "MaxUserDescriptionLength")]
36    pub max_user_description_length: u64,
37    pub is_user_description_enabled: bool,
38    #[serde(default, rename = "isUserEmailOnVerificationEnabled")]
39    pub is_user_email_on_verification_enabled: bool,
40    #[serde(default, rename = "isUserAgreementsSignupEnabled")]
41    pub is_user_agreements_signup_enabled: bool,
42    #[serde(default)]
43    pub is_user_block_endpoints_updated: bool,
44    #[serde(default)]
45    pub should_use_persona_for_id_verification: bool,
46    #[serde(default)]
47    pub should_display_session_management: bool,
48    #[serde(default)]
49    pub is_password_required_for_aging_down: bool,
50}
51
52endpoint! {
53    roblox_badges(id: u64) -> Vec<RobloxBadge> {
54        GET "{URL}/users/{id}/roblox-badges";
55    }
56
57    birthdate() -> DateTime {
58        GET "{URL}/birthdate";
59        types {
60            BirthdateResponse {
61                day("birthDay"): u8,
62                month("birthMonth"): u8,
63                year("birthYear"): i32,
64            }
65        }
66        map |res: BirthdateResponse| DateTime::from_ymd(res.year, res.month, res.day)
67    }
68
69    description() -> String {
70        GET "{URL}/description";
71        types {
72            DescriptionResponse {
73                value("description"): String,
74            }
75        }
76        map |res: DescriptionResponse| res.value
77    }
78
79    gender() -> Gender {
80        GET "{URL}/gender";
81        types {
82            GenderResponse {
83                value("gender"): u8,
84            }
85        }
86        map |res: GenderResponse| Gender::from_repr(res.value).expect("failed to parse gender")
87    }
88
89    metadata() -> Metadata {
90        GET "{URL}/metadata";
91    }
92
93    promotion_channels() -> PromotionChannels {
94        GET "{URL}/promotion-channels";
95    }
96
97    star_code_affiliate() -> u64 {
98        GET "{URL}/star-code-affiliates";
99        types {
100            StarCodeAffiliateResponse {
101                id("userId"): u64,
102            }
103        }
104        map |res: StarCodeAffiliateResponse| res.id
105    }
106}