use std::collections::HashMap;
use steamid::SteamID;
use super::super::{RemoteSteamUser, RemoteSteamUserError};
use crate::types::{CommunitySearchResult, FriendDetails, FriendListPage, PendingFriendList};
impl RemoteSteamUser {
pub async fn add_friend(&self, steam_id: SteamID) -> Result<(), RemoteSteamUserError> {
self.call_void("/api/friends/add", serde_json::json!({"steam_id": steam_id.steam_id64()})).await
}
pub async fn remove_friend(&self, steam_id: SteamID) -> Result<(), RemoteSteamUserError> {
self.call_void("/api/friends/remove", serde_json::json!({"steam_id": steam_id.steam_id64()})).await
}
pub async fn accept_friend_request(&self, steam_id: SteamID) -> Result<(), RemoteSteamUserError> {
self.call_void("/api/friends/accept", serde_json::json!({"steam_id": steam_id.steam_id64()})).await
}
pub async fn ignore_friend_request(&self, steam_id: SteamID) -> Result<(), RemoteSteamUserError> {
self.call_void("/api/friends/ignore", serde_json::json!({"steam_id": steam_id.steam_id64()})).await
}
pub async fn block_user(&self, steam_id: SteamID) -> Result<(), RemoteSteamUserError> {
self.call_void("/api/friends/block", serde_json::json!({"steam_id": steam_id.steam_id64()})).await
}
pub async fn unblock_user(&self, steam_id: SteamID) -> Result<(), RemoteSteamUserError> {
self.call_void("/api/friends/unblock", serde_json::json!({"steam_id": steam_id.steam_id64()})).await
}
pub async fn get_friends_list(&self) -> Result<HashMap<SteamID, i32>, RemoteSteamUserError> {
self.call_typed("/api/friends/list", serde_json::json!({})).await
}
pub async fn get_friends_details(&self) -> Result<FriendListPage, RemoteSteamUserError> {
self.call_typed("/api/friends/details", serde_json::json!({})).await
}
pub async fn get_friends_details_of_user(&self, steam_id: SteamID) -> Result<FriendListPage, RemoteSteamUserError> {
self.call_typed("/api/friends/details_of_user", serde_json::json!({"steam_id": steam_id.steam_id64()})).await
}
pub async fn search_users(&self, query: &str, page: u32) -> Result<CommunitySearchResult, RemoteSteamUserError> {
self.call_typed("/api/friends/search", serde_json::json!({"query": query, "page": page})).await
}
pub async fn create_instant_invite(&self) -> Result<String, RemoteSteamUserError> {
self.call_typed("/api/friends/quick_invite", serde_json::json!({})).await
}
pub async fn follow_user(&self, steam_id: SteamID) -> Result<(), RemoteSteamUserError> {
self.call_void("/api/friends/follow", serde_json::json!({"steam_id": steam_id.steam_id64()})).await
}
pub async fn unfollow_user(&self, steam_id: SteamID) -> Result<(), RemoteSteamUserError> {
self.call_void("/api/friends/unfollow", serde_json::json!({"steam_id": steam_id.steam_id64()})).await
}
pub async fn get_following_list(&self) -> Result<FriendListPage, RemoteSteamUserError> {
self.call_typed("/api/friends/following_list", serde_json::json!({})).await
}
pub async fn get_following_list_of_user(&self, steam_id: SteamID) -> Result<FriendListPage, RemoteSteamUserError> {
self.call_typed("/api/friends/following_list_of_user", serde_json::json!({"steam_id": steam_id.steam_id64()})).await
}
pub async fn get_my_friends_id_list(&self) -> Result<Vec<SteamID>, RemoteSteamUserError> {
self.call_typed("/api/friends/id_list", serde_json::json!({})).await
}
pub async fn get_pending_friend_list(&self) -> Result<PendingFriendList, RemoteSteamUserError> {
self.call_typed("/api/friends/pending", serde_json::json!({})).await
}
pub async fn remove_friends(&self, steam_ids: &[SteamID]) -> Result<(), RemoteSteamUserError> {
let ids: Vec<u64> = steam_ids.iter().map(|id| id.steam_id64()).collect();
self.call_void("/api/friends/remove_many", serde_json::json!({"steam_ids": ids})).await
}
pub async fn unfollow_users(&self, steam_ids: &[SteamID]) -> Result<(), RemoteSteamUserError> {
let ids: Vec<u64> = steam_ids.iter().map(|id| id.steam_id64()).collect();
self.call_void("/api/friends/unfollow_many", serde_json::json!({"steam_ids": ids})).await
}
pub async fn cancel_friend_request(&self, steam_id: SteamID) -> Result<(), RemoteSteamUserError> {
self.call_void("/api/friends/cancel_request", serde_json::json!({"steam_id": steam_id.steam_id64()})).await
}
pub async fn get_friends_in_common(&self, steam_id: SteamID) -> Result<Vec<FriendDetails>, RemoteSteamUserError> {
self.call_typed("/api/friends/in_common", serde_json::json!({"steam_id": steam_id.steam_id64()})).await
}
}