use steamid::SteamID;
use super::super::{RemoteSteamUser, RemoteSteamUserError};
use crate::types::{AliasEntry, AvatarHistoryEntry, AvatarUploadResponse, SteamProfile, SteamUserProfile, UserSummaryProfile, UserSummaryXml};
impl RemoteSteamUser {
pub async fn get_profile(&self, steam_id: Option<SteamID>) -> Result<SteamProfile, RemoteSteamUserError> {
self.call_typed("/api/profile/get", serde_json::json!({"steam_id": steam_id.map(|s| s.steam_id64())})).await
}
pub async fn edit_profile(&self, settings: serde_json::Value) -> Result<(), RemoteSteamUserError> {
self.call_void("/api/profile/edit", serde_json::json!({"settings": settings})).await
}
pub async fn set_persona_name(&self, name: &str) -> Result<(), RemoteSteamUserError> {
self.call_void("/api/profile/set_name", serde_json::json!({"name": name})).await
}
pub async fn get_alias_history(&self, steam_id: SteamID) -> Result<Vec<AliasEntry>, RemoteSteamUserError> {
self.call_typed("/api/profile/aliases", serde_json::json!({"steam_id": steam_id.steam_id64()})).await
}
pub async fn clear_previous_aliases(&self) -> Result<(), RemoteSteamUserError> {
self.call_void("/api/profile/clear_aliases", serde_json::json!({})).await
}
pub async fn set_nickname(&self, steam_id: SteamID, nickname: &str) -> Result<(), RemoteSteamUserError> {
self.call_void("/api/profile/set_nickname", serde_json::json!({"steam_id": steam_id.steam_id64(), "nickname": nickname})).await
}
pub async fn remove_nickname(&self, steam_id: SteamID) -> Result<(), RemoteSteamUserError> {
self.call_void("/api/profile/remove_nickname", serde_json::json!({"steam_id": steam_id.steam_id64()})).await
}
pub async fn post_profile_status(&self, text: &str, app_id: Option<u32>) -> Result<u64, RemoteSteamUserError> {
self.call_typed("/api/profile/post_status", serde_json::json!({"text": text, "app_id": app_id})).await
}
pub async fn select_previous_avatar(&self, avatar_hash: &str) -> Result<(), RemoteSteamUserError> {
self.call_void("/api/profile/select_avatar", serde_json::json!({"avatar_hash": avatar_hash})).await
}
pub async fn setup_profile(&self) -> Result<bool, RemoteSteamUserError> {
self.call_typed("/api/profile/setup", serde_json::json!({})).await
}
pub async fn get_user_summary_from_xml(&self, steam_id: SteamID) -> Result<UserSummaryXml, RemoteSteamUserError> {
self.call_typed("/api/profile/summary_xml", serde_json::json!({"steam_id": steam_id.steam_id64()})).await
}
pub async fn get_user_summary_from_profile(&self, steam_id: Option<SteamID>) -> Result<UserSummaryProfile, RemoteSteamUserError> {
self.call_typed("/api/profile/summary_profile", serde_json::json!({"steam_id": steam_id.map(|s| s.steam_id64())})).await
}
pub async fn fetch_full_profile(&self, steam_id: SteamID) -> Result<SteamProfile, RemoteSteamUserError> {
self.call_typed("/api/profile/full", serde_json::json!({"steam_id": steam_id.steam_id64()})).await
}
pub async fn resolve_user(&self, steam_id: SteamID) -> Result<Option<SteamUserProfile>, RemoteSteamUserError> {
self.call_typed("/api/profile/resolve_user", serde_json::json!({"steam_id": steam_id.steam_id64()})).await
}
pub async fn get_avatar_history(&self) -> Result<Vec<AvatarHistoryEntry>, RemoteSteamUserError> {
self.call_typed("/api/profile/avatar_history", serde_json::json!({})).await
}
pub async fn upload_avatar_from_url(&self, url: &str) -> Result<AvatarUploadResponse, RemoteSteamUserError> {
self.call_typed("/api/profile/upload_avatar_url", serde_json::json!({"url": url})).await
}
}