1mod errors;
2mod games;
3mod https;
4mod users;
5
6pub use errors::ApiResult;
7pub use games::models::{DevProduct, Game, Server};
8pub use games::GameBuilder;
9pub use https::Https;
10pub use users::models::User;
11pub use users::UserBuilder;
12
13use reqwest::Method;
14
15#[allow(dead_code)]
18pub(crate) const AUTH: &str = "https://auth.roblox.com/v1/account/pin/unlock";
19#[allow(dead_code)]
20pub(crate) const ACCOUNT: &str = "https://accountinformation.roblox.com/v1";
21pub(crate) const FRIENDS: &str = "https://friends.roblox.com/v1/";
22#[allow(dead_code)]
23pub(crate) const MESSAGES: &str = "https://privatemessages.roblox.com/v1";
24pub(crate) const USER: &str = "https://users.roblox.com/v1";
25pub(crate) const GAMES: &str = "https://games.roblox.com/v1";
26#[allow(dead_code)]
27pub(crate) const GROUPS: &str = "https://groups.roblox.com/v1";
28#[allow(dead_code)]
29pub(crate) const PRESENCE: &str = "https://presence.roblox.com/v1/presence/users";
30#[allow(dead_code)]
31pub(crate) const ECONOMY: &str = "https://economy.roblox.com/v1/assets";
32#[allow(dead_code)]
33pub(crate) const INVENTORY: &str = "https://inventory.roblox.com";
34#[allow(dead_code)]
35pub(crate) const DEVPAGE: &str = "https://develop.roblox.com/v1/universes";
36
37#[derive(Debug, Clone)]
38pub struct Client {
39 pub session: crate::Https,
40}
41
42impl Default for Client {
43 fn default() -> Self {
44 Self::new()
45 }
46}
47
48impl Client {
49 pub fn new() -> Self {
51 Self {
52 session: crate::Https::new(),
53 }
54 }
55
56 pub async fn user(&mut self, builder: impl UserBuilder) -> User {
67 builder.new(&mut self.session).await
68 }
69
70 pub async fn current_user(self: &mut Client) -> User {
82 let data = self
83 .session
84 .request::<serde_json::Value>(Method::GET, "https://www.roblox.com/mobileapi/userinfo")
85 .await
86 .expect("Failed to get user info");
87
88 let builder = data.get("UserID").unwrap().as_u64().unwrap();
89 UserBuilder::new(builder, &mut self.session).await
90 }
91
92 pub async fn game(&self, builder: impl GameBuilder) -> ApiResult<Game> {
106 builder.new(&mut self.session.clone()).await
107 }
108}