Skip to main content

steam_user/
trait_impl.rs

1//! Trait implementation for `SteamUser`.
2//!
3//! Delegates every [`SteamUserApi`] method to the corresponding inherent
4//! method.  Most methods are direct passthrough; a few need SteamID
5//! conversion (trait uses `u64`, inherent methods use `SteamID`) or
6//! parameter transformation.
7
8use std::collections::HashMap;
9
10use async_trait::async_trait;
11use steamid::SteamID;
12
13use crate::{
14    action::{ActionContext, ApiAction},
15    types::{
16        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, MatchmakingStats,
17        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,
18    },
19    SteamUser, SteamUserApi, SteamUserError,
20};
21
22#[async_trait]
23impl SteamUserApi for SteamUser {
24    type Error = SteamUserError;
25
26    // =================================================================
27    // Account
28    // =================================================================
29
30    async fn get_account_details(&self) -> Result<AccountDetails, Self::Error> {
31        self.get_account_details().await.with_action(ApiAction::GetAccountDetails)
32    }
33    async fn get_steam_wallet_balance(&self) -> Result<WalletBalance, Self::Error> {
34        self.get_steam_wallet_balance().await.with_action(ApiAction::GetSteamWalletBalance)
35    }
36    async fn get_amount_spent_on_steam(&self) -> Result<String, Self::Error> {
37        self.get_amount_spent_on_steam().await.with_action(ApiAction::GetAmountSpentOnSteam)
38    }
39    async fn get_purchase_history(&self) -> Result<Vec<PurchaseHistoryItem>, Self::Error> {
40        self.get_purchase_history().await.with_action(ApiAction::GetPurchaseHistory)
41    }
42    async fn redeem_wallet_code(&self, code: &str) -> Result<RedeemWalletCodeResponse, Self::Error> {
43        self.redeem_wallet_code(code).await.with_action(ApiAction::RedeemWalletCode)
44    }
45    async fn parental_unlock(&self, pin: &str) -> Result<(), Self::Error> {
46        self.parental_unlock(pin).await.with_action(ApiAction::ParentalUnlock)
47    }
48
49    // =================================================================
50    // Activity
51    // =================================================================
52
53    async fn get_friend_activity(&self, start: Option<u64>) -> Result<FriendActivityResponse, Self::Error> {
54        self.get_friend_activity(start).await.with_action(ApiAction::GetFriendActivity)
55    }
56    async fn get_friend_activity_full(&self) -> Result<Vec<FriendActivity>, Self::Error> {
57        self.get_friend_activity_full().await.with_action(ApiAction::GetFriendActivityFull)
58    }
59    async fn comment_user_received_new_game(&self, steam_id: SteamID, thread_id: u64, comment: &str) -> Result<ActivityCommentResponse, Self::Error> {
60        self.comment_user_received_new_game(steam_id, thread_id, comment).await.with_action(ApiAction::CommentUserReceivedNewGame)
61    }
62    async fn rate_up_user_received_new_game(&self, steam_id: SteamID, thread_id: u64) -> Result<ActivityCommentResponse, Self::Error> {
63        self.rate_up_user_received_new_game(steam_id, thread_id).await.with_action(ApiAction::RateUpUserReceivedNewGame)
64    }
65    async fn delete_comment_user_received_new_game(&self, steam_id: SteamID, thread_id: u64, comment_id: &str) -> Result<ActivityCommentResponse, Self::Error> {
66        self.delete_comment_user_received_new_game(steam_id, thread_id, comment_id).await.with_action(ApiAction::DeleteCommentUserReceivedNewGame)
67    }
68
69    // =================================================================
70    // Apps
71    // =================================================================
72
73    async fn get_owned_apps(&self) -> Result<Vec<OwnedApp>, Self::Error> {
74        self.get_owned_apps().await.with_action(ApiAction::GetOwnedApps)
75    }
76    async fn get_owned_apps_id(&self) -> Result<Vec<u32>, Self::Error> {
77        self.get_owned_apps_id().await.with_action(ApiAction::GetOwnedAppsId)
78    }
79    async fn get_owned_apps_detail(&self) -> Result<Vec<OwnedAppDetail>, Self::Error> {
80        self.get_owned_apps_detail().await.with_action(ApiAction::GetOwnedAppsDetail)
81    }
82    async fn get_app_detail(&self, app_ids: &[u32]) -> Result<HashMap<u32, AppDetail>, Self::Error> {
83        self.get_app_detail(app_ids).await.with_action(ApiAction::GetAppDetail)
84    }
85    async fn fetch_csgo_account_stats(&self) -> Result<CsgoAccountStats, Self::Error> {
86        self.fetch_csgo_account_stats().await.with_action(ApiAction::FetchCsgoAccountStats)
87    }
88    async fn fetch_matchmaking_stats(&self) -> Result<MatchmakingStats, Self::Error> {
89        self.fetch_matchmaking_stats().await.with_action(ApiAction::FetchMatchmakingStats)
90    }
91    async fn get_app_list(&self) -> Result<SimpleSteamAppList, Self::Error> {
92        SteamUser::get_app_list().await.with_action(ApiAction::GetAppList)
93    }
94    async fn suggest_app_list(&self, term: &str) -> Result<Vec<AppListItem>, Self::Error> {
95        SteamUser::suggest_app_list(term).await.with_action(ApiAction::SuggestAppList)
96    }
97    async fn query_app_list(&self, term: &str) -> Result<Vec<AppListItem>, Self::Error> {
98        SteamUser::query_app_list(term).await.with_action(ApiAction::QueryAppList)
99    }
100    async fn get_steam_app_version_info(&self, app_id: u32) -> Result<SteamAppVersionInfo, Self::Error> {
101        SteamUser::get_steam_app_version_info(app_id).await.with_action(ApiAction::GetSteamAppVersionInfo)
102    }
103    async fn get_dynamic_store_user_data(&self) -> Result<DynamicStoreUserData, Self::Error> {
104        self.get_dynamic_store_user_data().await.with_action(ApiAction::GetDynamicStoreUserData)
105    }
106    async fn fetch_batched_loyalty_reward_items(&self, app_ids: &[u32]) -> Result<Vec<steam_protos::messages::CLoyaltyRewardsBatchedQueryRewardItemsResponseResponse>, Self::Error> {
107        self.fetch_batched_loyalty_reward_items(app_ids).await.with_action(ApiAction::FetchBatchedLoyaltyRewardItems)
108    }
109
110    // =================================================================
111    // Comments
112    // =================================================================
113
114    async fn get_my_comments(&self) -> Result<Vec<UserComment>, Self::Error> {
115        self.get_my_comments().await.with_action(ApiAction::GetMyComments)
116    }
117    async fn get_user_comments(&self, steam_id: SteamID) -> Result<Vec<UserComment>, Self::Error> {
118        self.get_user_comments(steam_id).await.with_action(ApiAction::GetUserComments)
119    }
120    async fn post_comment(&self, steam_id: SteamID, message: &str) -> Result<Option<UserComment>, Self::Error> {
121        self.post_comment(steam_id, message).await.with_action(ApiAction::PostComment)
122    }
123    async fn delete_comment(&self, steam_id: SteamID, gidcomment: &str) -> Result<(), Self::Error> {
124        self.delete_comment(steam_id, gidcomment).await.with_action(ApiAction::DeleteComment)
125    }
126
127    // =================================================================
128    // Confirmations
129    // =================================================================
130
131    async fn get_confirmations(&self, identity_secret: &str, tag: Option<&str>) -> Result<Vec<Confirmation>, Self::Error> {
132        self.get_confirmations(identity_secret, tag).await.with_action(ApiAction::GetConfirmations)
133    }
134    async fn accept_confirmation_for_object(&self, identity_secret: &str, object_id: u64) -> Result<(), Self::Error> {
135        self.accept_confirmation_for_object(identity_secret, object_id).await.with_action(ApiAction::AcceptConfirmationForObject)
136    }
137    async fn deny_confirmation_for_object(&self, identity_secret: &str, object_id: u64) -> Result<(), Self::Error> {
138        self.deny_confirmation_for_object(identity_secret, object_id).await.with_action(ApiAction::DenyConfirmationForObject)
139    }
140
141    // =================================================================
142    // Email
143    // =================================================================
144
145    async fn get_account_email(&self) -> Result<String, Self::Error> {
146        self.get_account_email().await.with_action(ApiAction::GetAccountEmail)
147    }
148    async fn get_current_steam_login(&self) -> Result<String, Self::Error> {
149        self.get_current_steam_login().await.with_action(ApiAction::GetCurrentSteamLogin)
150    }
151
152    // =================================================================
153    // Friends
154    // =================================================================
155
156    async fn add_friend(&self, steam_id: SteamID) -> Result<(), Self::Error> {
157        self.add_friend(steam_id).await.with_action(ApiAction::AddFriend)
158    }
159    async fn remove_friend(&self, steam_id: SteamID) -> Result<(), Self::Error> {
160        self.remove_friend(steam_id).await.with_action(ApiAction::RemoveFriend)
161    }
162    async fn accept_friend_request(&self, steam_id: SteamID) -> Result<(), Self::Error> {
163        self.accept_friend_request(steam_id).await.with_action(ApiAction::AcceptFriendRequest)
164    }
165    async fn ignore_friend_request(&self, steam_id: SteamID) -> Result<(), Self::Error> {
166        self.ignore_friend_request(steam_id).await.with_action(ApiAction::IgnoreFriendRequest)
167    }
168    async fn block_user(&self, steam_id: SteamID) -> Result<(), Self::Error> {
169        self.block_user(steam_id).await.with_action(ApiAction::BlockUser)
170    }
171    async fn unblock_user(&self, steam_id: SteamID) -> Result<(), Self::Error> {
172        self.unblock_user(steam_id).await.with_action(ApiAction::UnblockUser)
173    }
174    async fn get_friends_list(&self) -> Result<HashMap<SteamID, i32>, Self::Error> {
175        self.get_friends_list().await.with_action(ApiAction::GetFriendsList)
176    }
177    async fn get_friends_details(&self) -> Result<FriendListPage, Self::Error> {
178        self.get_friends_details().await.with_action(ApiAction::GetFriendsDetails)
179    }
180    async fn get_friends_details_of_user(&self, steam_id: SteamID) -> Result<FriendListPage, Self::Error> {
181        self.get_friends_details_of_user(steam_id).await.with_action(ApiAction::GetFriendsDetailsOfUser)
182    }
183    async fn search_users(&self, query: &str, page: u32) -> Result<CommunitySearchResult, Self::Error> {
184        self.search_users(query, page).await.with_action(ApiAction::SearchUsers)
185    }
186    async fn create_instant_invite(&self) -> Result<String, Self::Error> {
187        self.create_instant_invite().await.with_action(ApiAction::CreateInstantInvite)
188    }
189    async fn follow_user(&self, steam_id: SteamID) -> Result<(), Self::Error> {
190        self.follow_user(steam_id).await.with_action(ApiAction::FollowUser)
191    }
192    async fn unfollow_user(&self, steam_id: SteamID) -> Result<(), Self::Error> {
193        self.unfollow_user(steam_id).await.with_action(ApiAction::UnfollowUser)
194    }
195    async fn get_following_list(&self) -> Result<FriendListPage, Self::Error> {
196        self.get_following_list().await.with_action(ApiAction::GetFollowingList)
197    }
198    async fn get_following_list_of_user(&self, steam_id: SteamID) -> Result<FriendListPage, Self::Error> {
199        self.get_following_list_of_user(steam_id).await.with_action(ApiAction::GetFollowingListOfUser)
200    }
201    async fn get_my_friends_id_list(&self) -> Result<Vec<SteamID>, Self::Error> {
202        self.get_my_friends_id_list().await.with_action(ApiAction::GetMyFriendsIdList)
203    }
204    async fn get_pending_friend_list(&self) -> Result<PendingFriendList, Self::Error> {
205        self.get_pending_friend_list().await.with_action(ApiAction::GetPendingFriendList)
206    }
207    async fn remove_friends(&self, steam_ids: &[SteamID]) -> Result<(), Self::Error> {
208        self.remove_friends(steam_ids).await.with_action(ApiAction::RemoveFriends)
209    }
210    async fn unfollow_users(&self, steam_ids: &[SteamID]) -> Result<(), Self::Error> {
211        self.unfollow_users(steam_ids).await.with_action(ApiAction::UnfollowUsers)
212    }
213    async fn cancel_friend_request(&self, steam_id: SteamID) -> Result<(), Self::Error> {
214        self.cancel_friend_request(steam_id).await.with_action(ApiAction::CancelFriendRequest)
215    }
216    async fn get_friends_in_common(&self, steam_id: SteamID) -> Result<Vec<FriendDetails>, Self::Error> {
217        self.get_friends_in_common(steam_id).await.with_action(ApiAction::GetFriendsInCommon)
218    }
219    async fn get_friends_gameplay_info(&self, app_id: u32) -> Result<crate::types::gameplay::GameplayInfoResponse, Self::Error> {
220        self.get_friends_gameplay_info(app_id).await.with_action(ApiAction::GetFriendsGameplayInfo)
221    }
222    async fn get_friend_since(&self, steam_id: SteamID) -> Result<Option<String>, Self::Error> {
223        self.get_friend_since(steam_id).await.with_action(ApiAction::GetFriendSince)
224    }
225    async fn get_quick_invite_data(&self) -> Result<crate::types::QuickInviteData, Self::Error> {
226        self.get_quick_invite_data().await.with_action(ApiAction::GetQuickInviteData)
227    }
228    async fn get_current_quick_invite_tokens(&self) -> Result<crate::types::QuickInviteTokensResponse, Self::Error> {
229        self.get_current_quick_invite_tokens().await.with_action(ApiAction::GetCurrentQuickInviteTokens)
230    }
231
232    // =================================================================
233    // Groups
234    // =================================================================
235
236    async fn join_group(&self, group_id: SteamID) -> Result<(), Self::Error> {
237        self.join_group(group_id).await.with_action(ApiAction::JoinGroup)
238    }
239    async fn leave_group(&self, group_id: SteamID) -> Result<(), Self::Error> {
240        self.leave_group(group_id).await.with_action(ApiAction::LeaveGroup)
241    }
242    async fn get_group_members(&self, group_id: SteamID) -> Result<Vec<SteamID>, Self::Error> {
243        self.get_group_members(group_id).await.with_action(ApiAction::GetGroupMembers)
244    }
245    async fn post_group_announcement(&self, group_id: SteamID, headline: &str, content: &str) -> Result<(), Self::Error> {
246        self.post_group_announcement(group_id, headline, content).await.with_action(ApiAction::PostGroupAnnouncement)
247    }
248    async fn kick_group_member(&self, group_id: SteamID, member_id: SteamID) -> Result<(), Self::Error> {
249        self.kick_group_member(group_id, member_id).await.with_action(ApiAction::KickGroupMember)
250    }
251    async fn invite_user_to_group(&self, user_id: SteamID, group_id: SteamID) -> Result<(), Self::Error> {
252        self.invite_user_to_group(user_id, group_id).await.with_action(ApiAction::InviteUserToGroup)
253    }
254    async fn invite_users_to_group(&self, user_ids: &[SteamID], group_id: SteamID) -> Result<(), Self::Error> {
255        self.invite_users_to_group(user_ids, group_id).await.with_action(ApiAction::InviteUsersToGroup)
256    }
257    async fn accept_group_invite(&self, group_id: SteamID) -> Result<(), Self::Error> {
258        self.accept_group_invite(group_id).await.with_action(ApiAction::AcceptGroupInvite)
259    }
260    async fn ignore_group_invite(&self, group_id: SteamID) -> Result<(), Self::Error> {
261        self.ignore_group_invite(group_id).await.with_action(ApiAction::IgnoreGroupInvite)
262    }
263    async fn get_group_overview(&self, gid: Option<SteamID>, group_url: Option<&str>, page: Option<i32>, search_key: Option<&str>) -> Result<GroupOverview, Self::Error> {
264        let options = crate::types::GroupOverviewOptions {
265            gid,
266            group_url: group_url.map(String::from),
267            page: page.unwrap_or(1),
268            search_key: search_key.map(String::from),
269        };
270        self.get_group_overview(options).await.with_action(ApiAction::GetGroupOverview)
271    }
272    async fn get_group_steam_id_from_vanity_url(&self, vanity_url: &str) -> Result<String, Self::Error> {
273        self.get_group_steam_id_from_vanity_url(vanity_url).await.with_action(ApiAction::GetGroupSteamIdFromVanityUrl)
274    }
275    async fn get_group_info_xml(&self, gid: Option<SteamID>, group_url: Option<&str>, page: Option<u32>) -> Result<GroupInfoXml, Self::Error> {
276        self.get_group_info_xml(gid, group_url, page).await.with_action(ApiAction::GetGroupInfoXml)
277    }
278    async fn get_group_info_xml_full(&self, gid: Option<SteamID>, group_url: Option<&str>) -> Result<GroupInfoXml, Self::Error> {
279        self.get_group_info_xml_full(gid, group_url).await.with_action(ApiAction::GetGroupInfoXmlFull)
280    }
281    async fn get_invitable_groups(&self, user_steam_id: SteamID) -> Result<Vec<InvitableGroup>, Self::Error> {
282        self.get_invitable_groups(user_steam_id).await.with_action(ApiAction::GetInvitableGroups)
283    }
284    async fn invite_all_friends_to_group(&self, group_id: SteamID) -> Result<(), Self::Error> {
285        self.invite_all_friends_to_group(group_id).await.with_action(ApiAction::InviteAllFriendsToGroup)
286    }
287
288    // =================================================================
289    // Inventory
290    // =================================================================
291
292    async fn get_inventory(&self, appid: AppId, context_id: ContextId) -> Result<Vec<EconItem>, Self::Error> {
293        self.get_inventory(appid, context_id).await.with_action(ApiAction::GetInventory)
294    }
295    async fn get_user_inventory_contents(&self, steam_id: SteamID, appid: AppId, context_id: ContextId) -> Result<Vec<EconItem>, Self::Error> {
296        self.get_user_inventory_contents(steam_id, appid, context_id).await.with_action(ApiAction::GetUserInventoryContents)
297    }
298    async fn get_inventory_history(&self) -> Result<InventoryHistoryResult, Self::Error> {
299        self.get_inventory_history(None).await.with_action(ApiAction::GetInventoryHistory)
300    }
301    async fn get_price_overview(&self, appid: AppId, market_hash_name: &str) -> Result<PriceOverview, Self::Error> {
302        self.get_price_overview(appid, market_hash_name).await.with_action(ApiAction::GetPriceOverview)
303    }
304    async fn get_active_inventories(&self) -> Result<Vec<ActiveInventory>, Self::Error> {
305        self.get_active_inventories().await.with_action(ApiAction::GetActiveInventories)
306    }
307    async fn get_inventory_trading(&self, appid: AppId, context_id: ContextId) -> Result<serde_json::Value, Self::Error> {
308        self.get_inventory_trading(appid, context_id).await.with_action(ApiAction::GetInventoryTrading)
309    }
310    async fn get_inventory_trading_partner(&self, appid: AppId, partner: SteamID, context_id: ContextId) -> Result<serde_json::Value, Self::Error> {
311        self.get_inventory_trading_partner(appid, partner, context_id).await.with_action(ApiAction::GetInventoryTradingPartner)
312    }
313    async fn get_full_inventory_history(&self) -> Result<Vec<InventoryHistoryItem>, Self::Error> {
314        self.get_full_inventory_history().await.with_action(ApiAction::GetFullInventoryHistory)
315    }
316
317    // =================================================================
318    // Market
319    // =================================================================
320
321    async fn get_my_listings(&self, start: u32, count: u32) -> Result<MyListingsResult, Self::Error> {
322        let (listings, assets, total_count) = self.get_my_listings(start, count).await.with_action(ApiAction::GetMyListings)?;
323        Ok(MyListingsResult { listings, assets, total_count })
324    }
325    async fn get_market_history(&self, start: u32, count: u32) -> Result<MarketHistoryResponse, Self::Error> {
326        self.get_market_history(start, count).await.with_action(ApiAction::GetMarketHistory)
327    }
328    async fn sell_item(&self, appid: AppId, contextid: ContextId, assetid: AssetId, amount: Amount, price: PriceCents) -> Result<SellItemResult, Self::Error> {
329        self.sell_item(appid, contextid, assetid, amount, price).await.with_action(ApiAction::SellItem)
330    }
331    async fn remove_listing(&self, listing_id: &str) -> Result<bool, Self::Error> {
332        self.remove_listing(listing_id).await.with_action(ApiAction::RemoveListing)
333    }
334    async fn get_gem_value(&self, appid: AppId, assetid: AssetId) -> Result<GemValue, Self::Error> {
335        self.get_gem_value(appid, assetid).await.with_action(ApiAction::GetGemValue)
336    }
337    async fn turn_item_into_gems(&self, appid: AppId, assetid: AssetId, expected_value: u32) -> Result<GemResult, Self::Error> {
338        self.turn_item_into_gems(appid, assetid, expected_value).await.with_action(ApiAction::TurnItemIntoGems)
339    }
340    async fn get_booster_pack_catalog(&self) -> Result<Vec<BoosterPackEntry>, Self::Error> {
341        self.get_booster_pack_catalog().await.with_action(ApiAction::GetBoosterPackCatalog)
342    }
343    async fn create_booster_pack(&self, appid: AppId, use_untradable_gems: bool) -> Result<BoosterResult, Self::Error> {
344        self.create_booster_pack(appid, use_untradable_gems).await.with_action(ApiAction::CreateBoosterPack)
345    }
346    async fn open_booster_pack(&self, appid: AppId, assetid: AssetId) -> Result<Vec<EconItem>, Self::Error> {
347        self.open_booster_pack(appid, assetid).await.with_action(ApiAction::OpenBoosterPack)
348    }
349    async fn get_market_restrictions(&self) -> Result<(MarketRestrictions, Option<WalletBalance>), Self::Error> {
350        self.get_market_restrictions().await.with_action(ApiAction::GetMarketRestrictions)
351    }
352    async fn get_market_apps(&self) -> Result<HashMap<u32, String>, Self::Error> {
353        self.get_market_apps().await.with_action(ApiAction::GetMarketApps)
354    }
355    async fn get_item_nameid(&self, app_id: AppId, market_hash_name: &str) -> Result<ItemNameId, Self::Error> {
356        self.get_item_nameid(app_id, market_hash_name).await.with_action(ApiAction::GetItemNameid)
357    }
358    async fn get_item_orders_histogram(&self, item_nameid: ItemNameId, country: &str, currency: u32) -> Result<ItemOrdersHistogramResponse, Self::Error> {
359        self.get_item_orders_histogram(item_nameid, country, currency).await.with_action(ApiAction::GetItemOrdersHistogram)
360    }
361
362    // =================================================================
363    // Phone
364    // =================================================================
365
366    async fn get_phone_number_status(&self) -> Result<Option<String>, Self::Error> {
367        self.get_phone_number_status().await.with_action(ApiAction::GetPhoneNumberStatus)
368    }
369    async fn add_phone_number(&self, phone: &str) -> Result<AddPhoneNumberResponse, Self::Error> {
370        self.add_phone_number(phone).await.with_action(ApiAction::AddPhoneNumber)
371    }
372    async fn confirm_phone_code_for_add(&self, code: &str) -> Result<ConfirmPhoneCodeResponse, Self::Error> {
373        self.confirm_phone_code_for_add(code).await.with_action(ApiAction::ConfirmPhoneCodeForAdd)
374    }
375    async fn resend_phone_verification_code(&self) -> Result<serde_json::Value, Self::Error> {
376        self.resend_phone_verification_code().await.with_action(ApiAction::ResendPhoneVerificationCode)
377    }
378    async fn get_remove_phone_number_type(&self) -> Result<Option<RemovePhoneResult>, Self::Error> {
379        self.get_remove_phone_number_type().await.with_action(ApiAction::GetRemovePhoneNumberType)
380    }
381    async fn send_account_recovery_code(&self, wizard_param: serde_json::Value, method: i32) -> Result<serde_json::Value, Self::Error> {
382        self.send_account_recovery_code(wizard_param, method).await.with_action(ApiAction::SendAccountRecoveryCode)
383    }
384    async fn confirm_remove_phone_number_code(&self, wizard_param: serde_json::Value, code: &str) -> Result<serde_json::Value, Self::Error> {
385        self.confirm_remove_phone_number_code(wizard_param, code).await.with_action(ApiAction::ConfirmRemovePhoneNumberCode)
386    }
387    async fn send_confirmation_2_steam_mobile_app(&self, wizard_param: serde_json::Value) -> Result<serde_json::Value, Self::Error> {
388        self.send_confirmation_2_steam_mobile_app(wizard_param).await.with_action(ApiAction::SendConfirmation2SteamMobileApp)
389    }
390    async fn send_confirmation_2_steam_mobile_app_final(&self, wizard_param: serde_json::Value) -> Result<serde_json::Value, Self::Error> {
391        self.send_confirmation_2_steam_mobile_app_final(wizard_param).await.with_action(ApiAction::SendConfirmation2SteamMobileAppFinal)
392    }
393
394    // =================================================================
395    // Privacy
396    // =================================================================
397
398    async fn get_privacy_settings(&self) -> Result<PrivacySettings, Self::Error> {
399        self.get_privacy_settings().await.with_action(ApiAction::GetPrivacySettings)
400    }
401    async fn set_privacy_settings(&self, settings: PrivacySettings) -> Result<PrivacySettings, Self::Error> {
402        self.set_privacy_settings(settings).await.with_action(ApiAction::SetPrivacySettings)
403    }
404    async fn set_all_privacy(&self, level: &str) -> Result<PrivacySettings, Self::Error> {
405        let state: crate::types::PrivacyState = serde_json::from_value(serde_json::json!(level)).map_err(|e| SteamUserError::Other(format!("Invalid privacy level: {}", e)))?;
406        self.set_all_privacy(state).await.with_action(ApiAction::SetAllPrivacy)
407    }
408
409    // =================================================================
410    // Profile
411    // =================================================================
412
413    async fn get_profile(&self, steam_id: Option<SteamID>) -> Result<SteamProfile, Self::Error> {
414        self.get_profile(steam_id).await.with_action(ApiAction::GetProfile)
415    }
416    async fn edit_profile(&self, _settings: serde_json::Value) -> Result<(), Self::Error> {
417        Err(SteamUserError::Other("edit_profile uses scraper (!Send) \u{2014} call the inherent method directly".into()))
418    }
419    async fn set_persona_name(&self, name: &str) -> Result<(), Self::Error> {
420        self.set_persona_name(name).await.with_action(ApiAction::SetPersonaName)
421    }
422    async fn get_alias_history(&self, steam_id: SteamID) -> Result<Vec<AliasEntry>, Self::Error> {
423        self.get_alias_history(steam_id).await.with_action(ApiAction::GetAliasHistory)
424    }
425    async fn clear_previous_aliases(&self) -> Result<(), Self::Error> {
426        self.clear_previous_aliases().await.with_action(ApiAction::ClearPreviousAliases)
427    }
428    async fn set_nickname(&self, steam_id: SteamID, nickname: &str) -> Result<(), Self::Error> {
429        self.set_nickname(steam_id, nickname).await.with_action(ApiAction::SetNickname)
430    }
431    async fn remove_nickname(&self, steam_id: SteamID) -> Result<(), Self::Error> {
432        self.remove_nickname(steam_id).await.with_action(ApiAction::RemoveNickname)
433    }
434    async fn post_profile_status(&self, text: &str, app_id: Option<u32>) -> Result<u64, Self::Error> {
435        self.post_profile_status(text, app_id).await.with_action(ApiAction::PostProfileStatus)
436    }
437    async fn select_previous_avatar(&self, avatar_hash: &str) -> Result<(), Self::Error> {
438        self.select_previous_avatar(avatar_hash).await.with_action(ApiAction::SelectPreviousAvatar)
439    }
440    async fn setup_profile(&self) -> Result<bool, Self::Error> {
441        self.setup_profile().await.with_action(ApiAction::SetupProfile)
442    }
443    async fn get_user_summary_from_xml(&self, steam_id: SteamID) -> Result<UserSummaryXml, Self::Error> {
444        self.get_user_summary_from_xml(steam_id).await.with_action(ApiAction::GetUserSummaryFromXml)
445    }
446    async fn get_user_summary_from_profile(&self, steam_id: Option<SteamID>) -> Result<UserSummaryProfile, Self::Error> {
447        self.get_user_summary_from_profile(steam_id).await.with_action(ApiAction::GetUserSummaryFromProfile)
448    }
449    async fn fetch_full_profile(&self, _steam_id: SteamID) -> Result<SteamProfile, Self::Error> {
450        Err(SteamUserError::Other("fetch_full_profile uses scraper (!Send) \u{2014} call the inherent method directly".into()))
451    }
452    async fn resolve_user(&self, steam_id: SteamID) -> Result<Option<SteamUserProfile>, Self::Error> {
453        self.resolve_user(steam_id).await.with_action(ApiAction::ResolveUser)
454    }
455    async fn get_avatar_history(&self) -> Result<Vec<AvatarHistoryEntry>, Self::Error> {
456        self.get_avatar_history().await.with_action(ApiAction::GetAvatarHistory)
457    }
458    async fn upload_avatar_from_url(&self, url: &str) -> Result<AvatarUploadResponse, Self::Error> {
459        self.upload_avatar_from_url(url).await.with_action(ApiAction::UploadAvatarFromUrl)
460    }
461
462    // =================================================================
463    // Tokens
464    // =================================================================
465
466    async fn enumerate_tokens(&self) -> Result<steam_protos::CAuthenticationRefreshTokenEnumerateResponse, Self::Error> {
467        self.enumerate_tokens().await.with_action(ApiAction::EnumerateTokens)
468    }
469    async fn check_token_exists(&self, token_id: &str) -> Result<bool, Self::Error> {
470        self.check_token_exists(token_id).await.with_action(ApiAction::CheckTokenExists)
471    }
472    async fn revoke_tokens(&self, token_ids: &[&str], shared_secret: Option<&str>) -> Result<crate::services::tokens::RevokeTokensResult, Self::Error> {
473        self.revoke_tokens(token_ids, shared_secret).await.with_action(ApiAction::RevokeTokens)
474    }
475
476    // =================================================================
477    // Trade
478    // =================================================================
479
480    async fn get_trade_url(&self) -> Result<Option<String>, Self::Error> {
481        self.get_trade_url().await.with_action(ApiAction::GetTradeUrl)
482    }
483    async fn get_trade_offer(&self) -> Result<TradeOffersResponse, Self::Error> {
484        self.get_trade_offer().await.with_action(ApiAction::GetTradeOffer)
485    }
486    async fn accept_trade_offer(&self, trade_offer_id: u64, partner_steam_id: Option<String>) -> Result<String, Self::Error> {
487        self.accept_trade_offer(trade_offer_id, partner_steam_id).await.with_action(ApiAction::AcceptTradeOffer)
488    }
489    async fn decline_trade_offer(&self, trade_offer_id: u64) -> Result<(), Self::Error> {
490        self.decline_trade_offer(trade_offer_id).await.with_action(ApiAction::DeclineTradeOffer)
491    }
492    async fn cancel_trade_offer(&self, trade_offer_id: u64) -> Result<(), Self::Error> {
493        self.cancel_trade_offer(trade_offer_id).await.with_action(ApiAction::CancelTradeOffer)
494    }
495    async fn send_trade_offer(&self, trade_url: &str, my_assets: Vec<TradeOfferAsset>, their_assets: Vec<TradeOfferAsset>, message: &str) -> Result<TradeOfferResult, Self::Error> {
496        self.send_trade_offer(trade_url, my_assets, their_assets, message).await.with_action(ApiAction::SendTradeOffer)
497    }
498    async fn get_sent_trade_offers(&self) -> Result<TradeOffersResponse, Self::Error> {
499        self.get_sent_trade_offers().await.with_action(ApiAction::GetSentTradeOffers)
500    }
501
502    // =================================================================
503    // Two-Factor Authentication
504    // =================================================================
505
506    async fn get_steam_guard_status(&self) -> Result<SteamGuardStatus, Self::Error> {
507        self.get_steam_guard_status().await.with_action(ApiAction::GetSteamGuardStatus)
508    }
509    async fn enable_two_factor(&self) -> Result<TwoFactorResponse, Self::Error> {
510        self.enable_two_factor().await.with_action(ApiAction::EnableTwoFactor)
511    }
512    async fn finalize_two_factor(&self, shared_secret: &str, activation_code: &str) -> Result<(), Self::Error> {
513        self.finalize_two_factor(shared_secret, activation_code).await.with_action(ApiAction::FinalizeTwoFactor)
514    }
515    async fn disable_two_factor(&self, revocation_code: &str) -> Result<(), Self::Error> {
516        self.disable_two_factor(revocation_code).await.with_action(ApiAction::DisableTwoFactor)
517    }
518    async fn deauthorize_devices(&self) -> Result<(), Self::Error> {
519        self.deauthorize_devices().await.with_action(ApiAction::DeauthorizeDevices)
520    }
521    async fn add_authenticator(&self) -> Result<TwoFactorResponse, Self::Error> {
522        self.add_authenticator().await.with_action(ApiAction::AddAuthenticator)
523    }
524    async fn finalize_authenticator(&self, activation_code: &str) -> Result<(), Self::Error> {
525        self.finalize_authenticator(activation_code).await.with_action(ApiAction::FinalizeAuthenticator)
526    }
527    async fn remove_authenticator(&self, revocation_code: &str) -> Result<(), Self::Error> {
528        self.remove_authenticator(revocation_code).await.with_action(ApiAction::RemoveAuthenticator)
529    }
530    async fn enable_steam_guard_email(&self) -> Result<bool, Self::Error> {
531        self.enable_steam_guard_email().await.with_action(ApiAction::EnableSteamGuardEmail)
532    }
533    async fn disable_steam_guard_email(&self) -> Result<bool, Self::Error> {
534        self.disable_steam_guard_email().await.with_action(ApiAction::DisableSteamGuardEmail)
535    }
536
537    // =================================================================
538    // Extra (reports, license, help, match history)
539    // =================================================================
540
541    async fn get_player_reports(&self) -> Result<Vec<PlayerReport>, Self::Error> {
542        self.get_player_reports().await.with_action(ApiAction::GetPlayerReports)
543    }
544    async fn add_free_license(&self, package_id: u32) -> Result<bool, Self::Error> {
545        self.add_free_license(package_id).await.with_action(ApiAction::AddFreeLicense)
546    }
547    async fn add_sub_free_license(&self, sub_id: u32) -> Result<bool, Self::Error> {
548        self.add_sub_free_license(sub_id).await.with_action(ApiAction::AddSubFreeLicense)
549    }
550    async fn redeem_points(&self, definition_id: u32) -> Result<steam_protos::messages::loyalty_rewards::CLoyaltyRewardsRedeemPointsResponse, Self::Error> {
551        self.redeem_points(definition_id).await.with_action(ApiAction::RedeemPoints)
552    }
553    async fn get_help_requests(&self) -> Result<Vec<HelpRequest>, Self::Error> {
554        self.get_help_requests().await.with_action(ApiAction::GetHelpRequests)
555    }
556    async fn get_help_request_detail(&self, id: &str) -> Result<String, Self::Error> {
557        self.get_help_request_detail(id).await.with_action(ApiAction::GetHelpRequestDetail)
558    }
559    async fn get_match_history(&self, match_type: &str, token: Option<&str>) -> Result<MatchHistoryResponse, Self::Error> {
560        let mt: crate::types::MatchHistoryType = match_type.parse().map_err(|_| SteamUserError::Other(format!("Invalid match type: {}", match_type)))?;
561        self.get_match_history(mt, token).await.with_action(ApiAction::GetMatchHistory)
562    }
563
564    // =================================================================
565    // Misc (notifications, web API, etc.)
566    // =================================================================
567
568    async fn logged_in(&self) -> Result<LoggedInResult, Self::Error> {
569        let (logged_in, family_view) = self.logged_in().await.with_action(ApiAction::LoggedIn)?;
570        Ok(LoggedInResult { logged_in, family_view })
571    }
572    async fn get_notifications(&self) -> Result<Notifications, Self::Error> {
573        self.get_notifications().await.with_action(ApiAction::GetNotifications)
574    }
575    async fn get_web_api_key(&self, _domain: &str) -> Result<String, Self::Error> {
576        Err(SteamUserError::Other("get_web_api_key uses scraper (!Send) \u{2014} call the inherent method directly".into()))
577    }
578    async fn resolve_vanity_url(&self, api_key: &str, vanity_name: &str) -> Result<SteamID, Self::Error> {
579        self.resolve_vanity_url(api_key, vanity_name).await.with_action(ApiAction::ResolveVanityUrl)
580    }
581    async fn revoke_web_api_key(&self) -> Result<(), Self::Error> {
582        self.revoke_web_api_key().await.with_action(ApiAction::RevokeWebApiKey)
583    }
584}