1use crate::error::HtbError;
2use crate::models::user::{UserInfo, UserInfoResponse, UserProfile, UserProfileResponse};
3
4use super::HtbClient;
5
6pub struct UserApi<'a>(pub(crate) &'a HtbClient);
7
8impl UserApi<'_> {
9 pub async fn current(&self) -> Result<UserInfo, HtbError> {
10 let resp: UserInfoResponse = self.0.get("/api/v4/user/info").await?;
11 Ok(resp.info)
12 }
13
14 pub async fn profile(&self, user_id: u64) -> Result<UserProfile, HtbError> {
15 let resp: UserProfileResponse = self
16 .0
17 .get(&format!("/api/v4/user/profile/basic/{user_id}"))
18 .await?;
19 Ok(resp.profile)
20 }
21}