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
pub mod asset_aliases;
pub mod asset_permissions;
pub mod assets;
pub mod badges;
pub mod developer_products;
pub mod errors;
pub mod experiences;
pub mod game_passes;
mod helpers;
pub mod models;
pub mod places;
pub mod social_links;
pub mod spatial_voice;
pub mod thumbnails;
use errors::{RobloxApiError, RobloxApiResult};
use helpers::handle;
use rbx_auth::{RobloxAuth, WithRobloxAuth};
pub struct RobloxApi {
client: reqwest::Client,
}
impl RobloxApi {
pub fn new(roblox_auth: RobloxAuth) -> RobloxApiResult<Self> {
Ok(Self {
client: reqwest::Client::builder()
.connection_verbose(true)
.user_agent("Roblox/WinInet")
.roblox_auth(roblox_auth)
.build()?,
})
}
pub async fn validate_auth(&self) -> RobloxApiResult<()> {
let req = self
.client
.get("https://users.roblox.com/v1/users/authenticated");
handle(req)
.await
.map_err(|_| RobloxApiError::Authorization)?;
Ok(())
}
}