//! Trait implementation for `SteamUser`.
//!
//! Delegates every [`SteamUserApi`] method to the corresponding inherent
//! method. Most methods are direct passthrough; a few need SteamID
//! conversion (trait uses `u64`, inherent methods use `SteamID`) or
//! parameter transformation.
use std::collections::HashMap;
use async_trait::async_trait;
use steamid::SteamID;
use crate::{
action::{ActionContext, ApiAction},
types::{
AccountDetails, ActiveInventory, ActivityCommentResponse, AddPhoneNumberResponse, AliasEntry, Amount, AppDetail, AppId, AppListItem, AssetId, AvatarHistoryEntry, AvatarUploadResponse, BoosterPackEntry, BoosterResult, CommunitySearchResult, ConfirmPhoneCodeResponse, Confirmation, ContextId, CsgoAccountStats, DynamicStoreUserData, EconItem, FriendActivity, FriendActivityResponse, FriendDetails, FriendListPage, GemResult, GemValue, GroupInfoXml, GroupOverview, HelpRequest, InventoryHistoryItem, InventoryHistoryResult, InvitableGroup, ItemNameId, ItemOrdersHistogramResponse, LoggedInResult, MarketHistoryResponse, MarketRestrictions,
MatchHistoryResponse, MyListingsResult, Notifications, OwnedApp, OwnedAppDetail, PendingFriendList, PlayerReport, PriceCents, PriceOverview, PrivacySettings, PurchaseHistoryItem, RedeemWalletCodeResponse, RemovePhoneResult, SellItemResult, SimpleSteamAppList, SteamAppVersionInfo, SteamGuardStatus, SteamProfile, SteamUserProfile, TradeOfferAsset, TradeOfferResult, TradeOffersResponse, TwoFactorResponse, UserComment, UserSummaryProfile, UserSummaryXml, WalletBalance,
},
SteamUser, SteamUserApi, SteamUserError,
};
#[async_trait]
impl SteamUserApi for SteamUser {
type Error = SteamUserError;
// =================================================================
// Account
// =================================================================
async fn get_account_details(&self) -> Result<AccountDetails, Self::Error> {
self.get_account_details().await.with_action(ApiAction::GetAccountDetails)
}
async fn get_steam_wallet_balance(&self) -> Result<WalletBalance, Self::Error> {
self.get_steam_wallet_balance().await.with_action(ApiAction::GetSteamWalletBalance)
}
async fn get_amount_spent_on_steam(&self) -> Result<String, Self::Error> {
self.get_amount_spent_on_steam().await.with_action(ApiAction::GetAmountSpentOnSteam)
}
async fn get_purchase_history(&self) -> Result<Vec<PurchaseHistoryItem>, Self::Error> {
self.get_purchase_history().await.with_action(ApiAction::GetPurchaseHistory)
}
async fn redeem_wallet_code(&self, code: &str) -> Result<RedeemWalletCodeResponse, Self::Error> {
self.redeem_wallet_code(code).await.with_action(ApiAction::RedeemWalletCode)
}
async fn parental_unlock(&self, pin: &str) -> Result<(), Self::Error> {
self.parental_unlock(pin).await.with_action(ApiAction::ParentalUnlock)
}
// =================================================================
// Activity
// =================================================================
async fn get_friend_activity(&self, start: Option<u64>) -> Result<FriendActivityResponse, Self::Error> {
self.get_friend_activity(start).await.with_action(ApiAction::GetFriendActivity)
}
async fn get_friend_activity_full(&self) -> Result<Vec<FriendActivity>, Self::Error> {
self.get_friend_activity_full().await.with_action(ApiAction::GetFriendActivityFull)
}
async fn comment_user_received_new_game(&self, steam_id: SteamID, thread_id: u64, comment: &str) -> Result<ActivityCommentResponse, Self::Error> {
self.comment_user_received_new_game(steam_id, thread_id, comment).await.with_action(ApiAction::CommentUserReceivedNewGame)
}
async fn rate_up_user_received_new_game(&self, steam_id: SteamID, thread_id: u64) -> Result<ActivityCommentResponse, Self::Error> {
self.rate_up_user_received_new_game(steam_id, thread_id).await.with_action(ApiAction::RateUpUserReceivedNewGame)
}
async fn delete_comment_user_received_new_game(&self, steam_id: SteamID, thread_id: u64, comment_id: &str) -> Result<ActivityCommentResponse, Self::Error> {
self.delete_comment_user_received_new_game(steam_id, thread_id, comment_id).await.with_action(ApiAction::DeleteCommentUserReceivedNewGame)
}
// =================================================================
// Apps
// =================================================================
async fn get_owned_apps(&self) -> Result<Vec<OwnedApp>, Self::Error> {
self.get_owned_apps().await.with_action(ApiAction::GetOwnedApps)
}
async fn get_owned_apps_id(&self) -> Result<Vec<u32>, Self::Error> {
self.get_owned_apps_id().await.with_action(ApiAction::GetOwnedAppsId)
}
async fn get_owned_apps_detail(&self) -> Result<Vec<OwnedAppDetail>, Self::Error> {
self.get_owned_apps_detail().await.with_action(ApiAction::GetOwnedAppsDetail)
}
async fn get_app_detail(&self, app_ids: &[u32]) -> Result<HashMap<u32, AppDetail>, Self::Error> {
self.get_app_detail(app_ids).await.with_action(ApiAction::GetAppDetail)
}
async fn fetch_csgo_account_stats(&self) -> Result<CsgoAccountStats, Self::Error> {
self.fetch_csgo_account_stats().await.with_action(ApiAction::FetchCsgoAccountStats)
}
async fn get_app_list(&self) -> Result<SimpleSteamAppList, Self::Error> {
SteamUser::get_app_list().await.with_action(ApiAction::GetAppList)
}
async fn suggest_app_list(&self, term: &str) -> Result<Vec<AppListItem>, Self::Error> {
SteamUser::suggest_app_list(term).await.with_action(ApiAction::SuggestAppList)
}
async fn query_app_list(&self, term: &str) -> Result<Vec<AppListItem>, Self::Error> {
SteamUser::query_app_list(term).await.with_action(ApiAction::QueryAppList)
}
async fn get_steam_app_version_info(&self, app_id: u32) -> Result<SteamAppVersionInfo, Self::Error> {
SteamUser::get_steam_app_version_info(app_id).await.with_action(ApiAction::GetSteamAppVersionInfo)
}
async fn get_dynamic_store_user_data(&self) -> Result<DynamicStoreUserData, Self::Error> {
self.get_dynamic_store_user_data().await.with_action(ApiAction::GetDynamicStoreUserData)
}
async fn fetch_batched_loyalty_reward_items(&self, app_ids: &[u32]) -> Result<Vec<steam_protos::messages::CLoyaltyRewardsBatchedQueryRewardItemsResponseResponse>, Self::Error> {
self.fetch_batched_loyalty_reward_items(app_ids).await.with_action(ApiAction::FetchBatchedLoyaltyRewardItems)
}
// =================================================================
// Comments
// =================================================================
async fn get_my_comments(&self) -> Result<Vec<UserComment>, Self::Error> {
self.get_my_comments().await.with_action(ApiAction::GetMyComments)
}
async fn get_user_comments(&self, steam_id: SteamID) -> Result<Vec<UserComment>, Self::Error> {
self.get_user_comments(steam_id).await.with_action(ApiAction::GetUserComments)
}
async fn post_comment(&self, steam_id: SteamID, message: &str) -> Result<Option<UserComment>, Self::Error> {
self.post_comment(steam_id, message).await.with_action(ApiAction::PostComment)
}
async fn delete_comment(&self, steam_id: SteamID, gidcomment: &str) -> Result<(), Self::Error> {
self.delete_comment(steam_id, gidcomment).await.with_action(ApiAction::DeleteComment)
}
// =================================================================
// Confirmations
// =================================================================
async fn get_confirmations(&self, identity_secret: &str, tag: Option<&str>) -> Result<Vec<Confirmation>, Self::Error> {
self.get_confirmations(identity_secret, tag).await.with_action(ApiAction::GetConfirmations)
}
async fn accept_confirmation_for_object(&self, identity_secret: &str, object_id: u64) -> Result<(), Self::Error> {
self.accept_confirmation_for_object(identity_secret, object_id).await.with_action(ApiAction::AcceptConfirmationForObject)
}
async fn deny_confirmation_for_object(&self, identity_secret: &str, object_id: u64) -> Result<(), Self::Error> {
self.deny_confirmation_for_object(identity_secret, object_id).await.with_action(ApiAction::DenyConfirmationForObject)
}
// =================================================================
// Email
// =================================================================
async fn get_account_email(&self) -> Result<String, Self::Error> {
self.get_account_email().await.with_action(ApiAction::GetAccountEmail)
}
async fn get_current_steam_login(&self) -> Result<String, Self::Error> {
self.get_current_steam_login().await.with_action(ApiAction::GetCurrentSteamLogin)
}
// =================================================================
// Friends
// =================================================================
async fn add_friend(&self, steam_id: SteamID) -> Result<(), Self::Error> {
self.add_friend(steam_id).await.with_action(ApiAction::AddFriend)
}
async fn remove_friend(&self, steam_id: SteamID) -> Result<(), Self::Error> {
self.remove_friend(steam_id).await.with_action(ApiAction::RemoveFriend)
}
async fn accept_friend_request(&self, steam_id: SteamID) -> Result<(), Self::Error> {
self.accept_friend_request(steam_id).await.with_action(ApiAction::AcceptFriendRequest)
}
async fn ignore_friend_request(&self, steam_id: SteamID) -> Result<(), Self::Error> {
self.ignore_friend_request(steam_id).await.with_action(ApiAction::IgnoreFriendRequest)
}
async fn block_user(&self, steam_id: SteamID) -> Result<(), Self::Error> {
self.block_user(steam_id).await.with_action(ApiAction::BlockUser)
}
async fn unblock_user(&self, steam_id: SteamID) -> Result<(), Self::Error> {
self.unblock_user(steam_id).await.with_action(ApiAction::UnblockUser)
}
async fn get_friends_list(&self) -> Result<HashMap<SteamID, i32>, Self::Error> {
self.get_friends_list().await.with_action(ApiAction::GetFriendsList)
}
async fn get_friends_details(&self) -> Result<FriendListPage, Self::Error> {
self.get_friends_details().await.with_action(ApiAction::GetFriendsDetails)
}
async fn get_friends_details_of_user(&self, steam_id: SteamID) -> Result<FriendListPage, Self::Error> {
self.get_friends_details_of_user(steam_id).await.with_action(ApiAction::GetFriendsDetailsOfUser)
}
async fn search_users(&self, query: &str, page: u32) -> Result<CommunitySearchResult, Self::Error> {
self.search_users(query, page).await.with_action(ApiAction::SearchUsers)
}
async fn create_instant_invite(&self) -> Result<String, Self::Error> {
self.create_instant_invite().await.with_action(ApiAction::CreateInstantInvite)
}
async fn follow_user(&self, steam_id: SteamID) -> Result<(), Self::Error> {
self.follow_user(steam_id).await.with_action(ApiAction::FollowUser)
}
async fn unfollow_user(&self, steam_id: SteamID) -> Result<(), Self::Error> {
self.unfollow_user(steam_id).await.with_action(ApiAction::UnfollowUser)
}
async fn get_following_list(&self) -> Result<FriendListPage, Self::Error> {
self.get_following_list().await.with_action(ApiAction::GetFollowingList)
}
async fn get_following_list_of_user(&self, steam_id: SteamID) -> Result<FriendListPage, Self::Error> {
self.get_following_list_of_user(steam_id).await.with_action(ApiAction::GetFollowingListOfUser)
}
async fn get_my_friends_id_list(&self) -> Result<Vec<SteamID>, Self::Error> {
self.get_my_friends_id_list().await.with_action(ApiAction::GetMyFriendsIdList)
}
async fn get_pending_friend_list(&self) -> Result<PendingFriendList, Self::Error> {
self.get_pending_friend_list().await.with_action(ApiAction::GetPendingFriendList)
}
async fn remove_friends(&self, steam_ids: &[SteamID]) -> Result<(), Self::Error> {
self.remove_friends(steam_ids).await.with_action(ApiAction::RemoveFriends)
}
async fn unfollow_users(&self, steam_ids: &[SteamID]) -> Result<(), Self::Error> {
self.unfollow_users(steam_ids).await.with_action(ApiAction::UnfollowUsers)
}
async fn cancel_friend_request(&self, steam_id: SteamID) -> Result<(), Self::Error> {
self.cancel_friend_request(steam_id).await.with_action(ApiAction::CancelFriendRequest)
}
async fn get_friends_in_common(&self, steam_id: SteamID) -> Result<Vec<FriendDetails>, Self::Error> {
self.get_friends_in_common(steam_id).await.with_action(ApiAction::GetFriendsInCommon)
}
// =================================================================
// Groups
// =================================================================
async fn join_group(&self, group_id: SteamID) -> Result<(), Self::Error> {
self.join_group(group_id).await.with_action(ApiAction::JoinGroup)
}
async fn leave_group(&self, group_id: SteamID) -> Result<(), Self::Error> {
self.leave_group(group_id).await.with_action(ApiAction::LeaveGroup)
}
async fn get_group_members(&self, group_id: SteamID) -> Result<Vec<SteamID>, Self::Error> {
self.get_group_members(group_id).await.with_action(ApiAction::GetGroupMembers)
}
async fn post_group_announcement(&self, group_id: SteamID, headline: &str, content: &str) -> Result<(), Self::Error> {
self.post_group_announcement(group_id, headline, content).await.with_action(ApiAction::PostGroupAnnouncement)
}
async fn kick_group_member(&self, group_id: SteamID, member_id: SteamID) -> Result<(), Self::Error> {
self.kick_group_member(group_id, member_id).await.with_action(ApiAction::KickGroupMember)
}
async fn invite_user_to_group(&self, user_id: SteamID, group_id: SteamID) -> Result<(), Self::Error> {
self.invite_user_to_group(user_id, group_id).await.with_action(ApiAction::InviteUserToGroup)
}
async fn invite_users_to_group(&self, user_ids: &[SteamID], group_id: SteamID) -> Result<(), Self::Error> {
self.invite_users_to_group(user_ids, group_id).await.with_action(ApiAction::InviteUsersToGroup)
}
async fn accept_group_invite(&self, group_id: SteamID) -> Result<(), Self::Error> {
self.accept_group_invite(group_id).await.with_action(ApiAction::AcceptGroupInvite)
}
async fn ignore_group_invite(&self, group_id: SteamID) -> Result<(), Self::Error> {
self.ignore_group_invite(group_id).await.with_action(ApiAction::IgnoreGroupInvite)
}
async fn get_group_overview(&self, gid: Option<SteamID>, group_url: Option<&str>, page: Option<i32>, search_key: Option<&str>) -> Result<GroupOverview, Self::Error> {
let options = crate::types::GroupOverviewOptions {
gid,
group_url: group_url.map(String::from),
page: page.unwrap_or(1),
search_key: search_key.map(String::from),
};
self.get_group_overview(options).await.with_action(ApiAction::GetGroupOverview)
}
async fn get_group_steam_id_from_vanity_url(&self, vanity_url: &str) -> Result<String, Self::Error> {
self.get_group_steam_id_from_vanity_url(vanity_url).await.with_action(ApiAction::GetGroupSteamIdFromVanityUrl)
}
async fn get_group_info_xml(&self, gid: Option<SteamID>, group_url: Option<&str>, page: Option<u32>) -> Result<GroupInfoXml, Self::Error> {
self.get_group_info_xml(gid, group_url, page).await.with_action(ApiAction::GetGroupInfoXml)
}
async fn get_group_info_xml_full(&self, gid: Option<SteamID>, group_url: Option<&str>) -> Result<GroupInfoXml, Self::Error> {
self.get_group_info_xml_full(gid, group_url).await.with_action(ApiAction::GetGroupInfoXmlFull)
}
async fn get_invitable_groups(&self, user_steam_id: SteamID) -> Result<Vec<InvitableGroup>, Self::Error> {
self.get_invitable_groups(user_steam_id).await.with_action(ApiAction::GetInvitableGroups)
}
async fn invite_all_friends_to_group(&self, group_id: SteamID) -> Result<(), Self::Error> {
self.invite_all_friends_to_group(group_id).await.with_action(ApiAction::InviteAllFriendsToGroup)
}
// =================================================================
// Inventory
// =================================================================
async fn get_inventory(&self, appid: AppId, context_id: ContextId) -> Result<Vec<EconItem>, Self::Error> {
self.get_inventory(appid, context_id).await.with_action(ApiAction::GetInventory)
}
async fn get_user_inventory_contents(&self, steam_id: SteamID, appid: AppId, context_id: ContextId) -> Result<Vec<EconItem>, Self::Error> {
self.get_user_inventory_contents(steam_id, appid, context_id).await.with_action(ApiAction::GetUserInventoryContents)
}
async fn get_inventory_history(&self) -> Result<InventoryHistoryResult, Self::Error> {
self.get_inventory_history(None).await.with_action(ApiAction::GetInventoryHistory)
}
async fn get_price_overview(&self, appid: AppId, market_hash_name: &str) -> Result<PriceOverview, Self::Error> {
self.get_price_overview(appid, market_hash_name).await.with_action(ApiAction::GetPriceOverview)
}
async fn get_active_inventories(&self) -> Result<Vec<ActiveInventory>, Self::Error> {
self.get_active_inventories().await.with_action(ApiAction::GetActiveInventories)
}
async fn get_inventory_trading(&self, appid: AppId, context_id: ContextId) -> Result<serde_json::Value, Self::Error> {
self.get_inventory_trading(appid, context_id).await.with_action(ApiAction::GetInventoryTrading)
}
async fn get_inventory_trading_partner(&self, appid: AppId, partner: SteamID, context_id: ContextId) -> Result<serde_json::Value, Self::Error> {
self.get_inventory_trading_partner(appid, partner, context_id).await.with_action(ApiAction::GetInventoryTradingPartner)
}
async fn get_full_inventory_history(&self) -> Result<Vec<InventoryHistoryItem>, Self::Error> {
self.get_full_inventory_history().await.with_action(ApiAction::GetFullInventoryHistory)
}
// =================================================================
// Market
// =================================================================
async fn get_my_listings(&self) -> Result<MyListingsResult, Self::Error> {
let (listings, assets, total_count) = self.get_my_listings(0, 100).await.with_action(ApiAction::GetMyListings)?;
Ok(MyListingsResult { listings, assets, total_count })
}
async fn get_market_history(&self, start: u32, count: u32) -> Result<MarketHistoryResponse, Self::Error> {
self.get_market_history(start, count).await.with_action(ApiAction::GetMarketHistory)
}
async fn sell_item(&self, appid: AppId, contextid: ContextId, assetid: AssetId, amount: Amount, price: PriceCents) -> Result<SellItemResult, Self::Error> {
self.sell_item(appid, contextid, assetid, amount, price).await.with_action(ApiAction::SellItem)
}
async fn remove_listing(&self, listing_id: &str) -> Result<bool, Self::Error> {
self.remove_listing(listing_id).await.with_action(ApiAction::RemoveListing)
}
async fn get_gem_value(&self, appid: AppId, assetid: AssetId) -> Result<GemValue, Self::Error> {
self.get_gem_value(appid, assetid).await.with_action(ApiAction::GetGemValue)
}
async fn turn_item_into_gems(&self, appid: AppId, assetid: AssetId, expected_value: u32) -> Result<GemResult, Self::Error> {
self.turn_item_into_gems(appid, assetid, expected_value).await.with_action(ApiAction::TurnItemIntoGems)
}
async fn get_booster_pack_catalog(&self) -> Result<Vec<BoosterPackEntry>, Self::Error> {
self.get_booster_pack_catalog().await.with_action(ApiAction::GetBoosterPackCatalog)
}
async fn create_booster_pack(&self, appid: AppId, use_untradable_gems: bool) -> Result<BoosterResult, Self::Error> {
self.create_booster_pack(appid, use_untradable_gems).await.with_action(ApiAction::CreateBoosterPack)
}
async fn open_booster_pack(&self, appid: AppId, assetid: AssetId) -> Result<Vec<EconItem>, Self::Error> {
self.open_booster_pack(appid, assetid).await.with_action(ApiAction::OpenBoosterPack)
}
async fn get_market_restrictions(&self) -> Result<(MarketRestrictions, Option<WalletBalance>), Self::Error> {
self.get_market_restrictions().await.with_action(ApiAction::GetMarketRestrictions)
}
async fn get_market_apps(&self) -> Result<HashMap<u32, String>, Self::Error> {
self.get_market_apps().await.with_action(ApiAction::GetMarketApps)
}
async fn get_item_nameid(&self, app_id: AppId, market_hash_name: &str) -> Result<ItemNameId, Self::Error> {
self.get_item_nameid(app_id, market_hash_name).await.with_action(ApiAction::GetItemNameid)
}
async fn get_item_orders_histogram(&self, item_nameid: ItemNameId, country: &str, currency: u32) -> Result<ItemOrdersHistogramResponse, Self::Error> {
self.get_item_orders_histogram(item_nameid, country, currency).await.with_action(ApiAction::GetItemOrdersHistogram)
}
// =================================================================
// Phone
// =================================================================
async fn get_phone_number_status(&self) -> Result<Option<String>, Self::Error> {
self.get_phone_number_status().await.with_action(ApiAction::GetPhoneNumberStatus)
}
async fn add_phone_number(&self, phone: &str) -> Result<AddPhoneNumberResponse, Self::Error> {
self.add_phone_number(phone).await.with_action(ApiAction::AddPhoneNumber)
}
async fn confirm_phone_code_for_add(&self, code: &str) -> Result<ConfirmPhoneCodeResponse, Self::Error> {
self.confirm_phone_code_for_add(code).await.with_action(ApiAction::ConfirmPhoneCodeForAdd)
}
async fn resend_phone_verification_code(&self) -> Result<serde_json::Value, Self::Error> {
self.resend_phone_verification_code().await.with_action(ApiAction::ResendPhoneVerificationCode)
}
async fn get_remove_phone_number_type(&self) -> Result<Option<RemovePhoneResult>, Self::Error> {
self.get_remove_phone_number_type().await.with_action(ApiAction::GetRemovePhoneNumberType)
}
async fn send_account_recovery_code(&self, wizard_param: serde_json::Value, method: i32) -> Result<serde_json::Value, Self::Error> {
self.send_account_recovery_code(wizard_param, method).await.with_action(ApiAction::SendAccountRecoveryCode)
}
async fn confirm_remove_phone_number_code(&self, wizard_param: serde_json::Value, code: &str) -> Result<serde_json::Value, Self::Error> {
self.confirm_remove_phone_number_code(wizard_param, code).await.with_action(ApiAction::ConfirmRemovePhoneNumberCode)
}
async fn send_confirmation_2_steam_mobile_app(&self, wizard_param: serde_json::Value) -> Result<serde_json::Value, Self::Error> {
self.send_confirmation_2_steam_mobile_app(wizard_param).await.with_action(ApiAction::SendConfirmation2SteamMobileApp)
}
async fn send_confirmation_2_steam_mobile_app_final(&self, wizard_param: serde_json::Value) -> Result<serde_json::Value, Self::Error> {
self.send_confirmation_2_steam_mobile_app_final(wizard_param).await.with_action(ApiAction::SendConfirmation2SteamMobileAppFinal)
}
// =================================================================
// Privacy
// =================================================================
async fn get_privacy_settings(&self) -> Result<PrivacySettings, Self::Error> {
self.get_privacy_settings().await.with_action(ApiAction::GetPrivacySettings)
}
async fn set_privacy_settings(&self, settings: PrivacySettings) -> Result<PrivacySettings, Self::Error> {
self.set_privacy_settings(settings).await.with_action(ApiAction::SetPrivacySettings)
}
async fn set_all_privacy(&self, level: &str) -> Result<PrivacySettings, Self::Error> {
let state: crate::types::PrivacyState = serde_json::from_value(serde_json::json!(level)).map_err(|e| SteamUserError::Other(format!("Invalid privacy level: {}", e)))?;
self.set_all_privacy(state).await.with_action(ApiAction::SetAllPrivacy)
}
// =================================================================
// Profile
// =================================================================
async fn get_profile(&self, steam_id: Option<SteamID>) -> Result<SteamProfile, Self::Error> {
self.get_profile(steam_id).await.with_action(ApiAction::GetProfile)
}
async fn edit_profile(&self, _settings: serde_json::Value) -> Result<(), Self::Error> {
Err(SteamUserError::Other("edit_profile uses scraper (!Send) \u{2014} call the inherent method directly".into()))
}
async fn set_persona_name(&self, name: &str) -> Result<(), Self::Error> {
self.set_persona_name(name).await.with_action(ApiAction::SetPersonaName)
}
async fn get_alias_history(&self, steam_id: SteamID) -> Result<Vec<AliasEntry>, Self::Error> {
self.get_alias_history(steam_id).await.with_action(ApiAction::GetAliasHistory)
}
async fn clear_previous_aliases(&self) -> Result<(), Self::Error> {
self.clear_previous_aliases().await.with_action(ApiAction::ClearPreviousAliases)
}
async fn set_nickname(&self, steam_id: SteamID, nickname: &str) -> Result<(), Self::Error> {
self.set_nickname(steam_id, nickname).await.with_action(ApiAction::SetNickname)
}
async fn remove_nickname(&self, steam_id: SteamID) -> Result<(), Self::Error> {
self.remove_nickname(steam_id).await.with_action(ApiAction::RemoveNickname)
}
async fn post_profile_status(&self, text: &str, app_id: Option<u32>) -> Result<u64, Self::Error> {
self.post_profile_status(text, app_id).await.with_action(ApiAction::PostProfileStatus)
}
async fn select_previous_avatar(&self, avatar_hash: &str) -> Result<(), Self::Error> {
self.select_previous_avatar(avatar_hash).await.with_action(ApiAction::SelectPreviousAvatar)
}
async fn setup_profile(&self) -> Result<bool, Self::Error> {
self.setup_profile().await.with_action(ApiAction::SetupProfile)
}
async fn get_user_summary_from_xml(&self, steam_id: SteamID) -> Result<UserSummaryXml, Self::Error> {
self.get_user_summary_from_xml(steam_id).await.with_action(ApiAction::GetUserSummaryFromXml)
}
async fn get_user_summary_from_profile(&self, steam_id: Option<SteamID>) -> Result<UserSummaryProfile, Self::Error> {
self.get_user_summary_from_profile(steam_id).await.with_action(ApiAction::GetUserSummaryFromProfile)
}
async fn fetch_full_profile(&self, _steam_id: SteamID) -> Result<SteamProfile, Self::Error> {
Err(SteamUserError::Other("fetch_full_profile uses scraper (!Send) \u{2014} call the inherent method directly".into()))
}
async fn resolve_user(&self, steam_id: SteamID) -> Result<Option<SteamUserProfile>, Self::Error> {
self.resolve_user(steam_id).await.with_action(ApiAction::ResolveUser)
}
async fn get_avatar_history(&self) -> Result<Vec<AvatarHistoryEntry>, Self::Error> {
self.get_avatar_history().await.with_action(ApiAction::GetAvatarHistory)
}
async fn upload_avatar_from_url(&self, url: &str) -> Result<AvatarUploadResponse, Self::Error> {
self.upload_avatar_from_url(url).await.with_action(ApiAction::UploadAvatarFromUrl)
}
// =================================================================
// Tokens
// =================================================================
async fn enumerate_tokens(&self) -> Result<steam_protos::CAuthenticationRefreshTokenEnumerateResponse, Self::Error> {
self.enumerate_tokens().await.with_action(ApiAction::EnumerateTokens)
}
async fn check_token_exists(&self, token_id: &str) -> Result<bool, Self::Error> {
self.check_token_exists(token_id).await.with_action(ApiAction::CheckTokenExists)
}
async fn revoke_tokens(&self, token_ids: &[&str], shared_secret: Option<&str>) -> Result<crate::services::tokens::RevokeTokensResult, Self::Error> {
self.revoke_tokens(token_ids, shared_secret).await.with_action(ApiAction::RevokeTokens)
}
// =================================================================
// Trade
// =================================================================
async fn get_trade_url(&self) -> Result<Option<String>, Self::Error> {
self.get_trade_url().await.with_action(ApiAction::GetTradeUrl)
}
async fn get_trade_offer(&self) -> Result<TradeOffersResponse, Self::Error> {
self.get_trade_offer().await.with_action(ApiAction::GetTradeOffer)
}
async fn accept_trade_offer(&self, trade_offer_id: u64, partner_steam_id: Option<String>) -> Result<String, Self::Error> {
self.accept_trade_offer(trade_offer_id, partner_steam_id).await.with_action(ApiAction::AcceptTradeOffer)
}
async fn decline_trade_offer(&self, trade_offer_id: u64) -> Result<(), Self::Error> {
self.decline_trade_offer(trade_offer_id).await.with_action(ApiAction::DeclineTradeOffer)
}
async fn send_trade_offer(&self, trade_url: &str, my_assets: Vec<TradeOfferAsset>, their_assets: Vec<TradeOfferAsset>, message: &str) -> Result<TradeOfferResult, Self::Error> {
self.send_trade_offer(trade_url, my_assets, their_assets, message).await.with_action(ApiAction::SendTradeOffer)
}
// =================================================================
// Two-Factor Authentication
// =================================================================
async fn get_steam_guard_status(&self) -> Result<SteamGuardStatus, Self::Error> {
self.get_steam_guard_status().await.with_action(ApiAction::GetSteamGuardStatus)
}
async fn enable_two_factor(&self) -> Result<TwoFactorResponse, Self::Error> {
self.enable_two_factor().await.with_action(ApiAction::EnableTwoFactor)
}
async fn finalize_two_factor(&self, shared_secret: &str, activation_code: &str) -> Result<(), Self::Error> {
self.finalize_two_factor(shared_secret, activation_code).await.with_action(ApiAction::FinalizeTwoFactor)
}
async fn disable_two_factor(&self, revocation_code: &str) -> Result<(), Self::Error> {
self.disable_two_factor(revocation_code).await.with_action(ApiAction::DisableTwoFactor)
}
async fn deauthorize_devices(&self) -> Result<(), Self::Error> {
self.deauthorize_devices().await.with_action(ApiAction::DeauthorizeDevices)
}
async fn add_authenticator(&self) -> Result<TwoFactorResponse, Self::Error> {
self.add_authenticator().await.with_action(ApiAction::AddAuthenticator)
}
async fn finalize_authenticator(&self, activation_code: &str) -> Result<(), Self::Error> {
self.finalize_authenticator(activation_code).await.with_action(ApiAction::FinalizeAuthenticator)
}
async fn remove_authenticator(&self, revocation_code: &str) -> Result<(), Self::Error> {
self.remove_authenticator(revocation_code).await.with_action(ApiAction::RemoveAuthenticator)
}
async fn enable_steam_guard_email(&self) -> Result<bool, Self::Error> {
self.enable_steam_guard_email().await.with_action(ApiAction::EnableSteamGuardEmail)
}
async fn disable_steam_guard_email(&self) -> Result<bool, Self::Error> {
self.disable_steam_guard_email().await.with_action(ApiAction::DisableSteamGuardEmail)
}
// =================================================================
// Extra (reports, license, help, match history)
// =================================================================
async fn get_player_reports(&self) -> Result<Vec<PlayerReport>, Self::Error> {
self.get_player_reports().await.with_action(ApiAction::GetPlayerReports)
}
async fn add_free_license(&self, package_id: u32) -> Result<bool, Self::Error> {
self.add_free_license(package_id).await.with_action(ApiAction::AddFreeLicense)
}
async fn add_sub_free_license(&self, sub_id: u32) -> Result<bool, Self::Error> {
self.add_sub_free_license(sub_id).await.with_action(ApiAction::AddSubFreeLicense)
}
async fn redeem_points(&self, definition_id: u32) -> Result<steam_protos::messages::loyalty_rewards::CLoyaltyRewardsRedeemPointsResponse, Self::Error> {
self.redeem_points(definition_id).await.with_action(ApiAction::RedeemPoints)
}
async fn get_help_requests(&self) -> Result<Vec<HelpRequest>, Self::Error> {
self.get_help_requests().await.with_action(ApiAction::GetHelpRequests)
}
async fn get_help_request_detail(&self, id: &str) -> Result<String, Self::Error> {
self.get_help_request_detail(id).await.with_action(ApiAction::GetHelpRequestDetail)
}
async fn get_match_history(&self, match_type: &str, token: Option<&str>) -> Result<MatchHistoryResponse, Self::Error> {
let mt: crate::types::MatchHistoryType = match_type.parse().map_err(|_| SteamUserError::Other(format!("Invalid match type: {}", match_type)))?;
self.get_match_history(mt, token).await.with_action(ApiAction::GetMatchHistory)
}
// =================================================================
// Misc (notifications, web API, etc.)
// =================================================================
async fn logged_in(&self) -> Result<LoggedInResult, Self::Error> {
let (logged_in, family_view) = self.logged_in().await.with_action(ApiAction::LoggedIn)?;
Ok(LoggedInResult { logged_in, family_view })
}
async fn get_notifications(&self) -> Result<Notifications, Self::Error> {
self.get_notifications().await.with_action(ApiAction::GetNotifications)
}
async fn get_web_api_key(&self, _domain: &str) -> Result<String, Self::Error> {
Err(SteamUserError::Other("get_web_api_key uses scraper (!Send) \u{2014} call the inherent method directly".into()))
}
async fn resolve_vanity_url(&self, api_key: &str, vanity_name: &str) -> Result<SteamID, Self::Error> {
self.resolve_vanity_url(api_key, vanity_name).await.with_action(ApiAction::ResolveVanityUrl)
}
async fn revoke_web_api_key(&self) -> Result<(), Self::Error> {
self.revoke_web_api_key().await.with_action(ApiAction::RevokeWebApiKey)
}
}