steam-user 0.1.0

Steam User web client for Rust - HTTP-based Steam Community interactions
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
//! 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)
    }
}