use crate::error::SteamUserError;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum ApiAction {
GetAccountDetails,
GetSteamWalletBalance,
GetAmountSpentOnSteam,
GetPurchaseHistory,
RedeemWalletCode,
ParentalUnlock,
GetFriendActivity,
GetFriendActivityFull,
CommentUserReceivedNewGame,
RateUpUserReceivedNewGame,
DeleteCommentUserReceivedNewGame,
GetOwnedApps,
GetOwnedAppsId,
GetOwnedAppsDetail,
GetAppDetail,
FetchCsgoAccountStats,
GetAppList,
SuggestAppList,
QueryAppList,
GetSteamAppVersionInfo,
GetDynamicStoreUserData,
FetchBatchedLoyaltyRewardItems,
GetMyComments,
GetUserComments,
PostComment,
DeleteComment,
GetConfirmations,
AcceptConfirmationForObject,
DenyConfirmationForObject,
GetAccountEmail,
GetCurrentSteamLogin,
AddFriend,
RemoveFriend,
AcceptFriendRequest,
IgnoreFriendRequest,
BlockUser,
UnblockUser,
GetFriendsList,
GetFriendsDetails,
GetFriendsDetailsOfUser,
SearchUsers,
CreateInstantInvite,
FollowUser,
UnfollowUser,
GetFollowingList,
GetFollowingListOfUser,
GetMyFriendsIdList,
GetPendingFriendList,
RemoveFriends,
UnfollowUsers,
CancelFriendRequest,
GetFriendsInCommon,
JoinGroup,
LeaveGroup,
GetGroupMembers,
PostGroupAnnouncement,
KickGroupMember,
InviteUserToGroup,
InviteUsersToGroup,
AcceptGroupInvite,
IgnoreGroupInvite,
GetGroupOverview,
GetGroupSteamIdFromVanityUrl,
GetGroupInfoXml,
GetGroupInfoXmlFull,
GetInvitableGroups,
InviteAllFriendsToGroup,
GetInventory,
GetUserInventoryContents,
GetInventoryHistory,
GetPriceOverview,
GetActiveInventories,
GetInventoryTrading,
GetInventoryTradingPartner,
GetFullInventoryHistory,
GetMyListings,
GetMarketHistory,
SellItem,
RemoveListing,
GetGemValue,
TurnItemIntoGems,
GetBoosterPackCatalog,
CreateBoosterPack,
OpenBoosterPack,
GetMarketRestrictions,
GetMarketApps,
GetItemNameid,
GetItemOrdersHistogram,
GetPhoneNumberStatus,
AddPhoneNumber,
ConfirmPhoneCodeForAdd,
ResendPhoneVerificationCode,
GetRemovePhoneNumberType,
SendAccountRecoveryCode,
ConfirmRemovePhoneNumberCode,
SendConfirmation2SteamMobileApp,
SendConfirmation2SteamMobileAppFinal,
GetPrivacySettings,
SetPrivacySettings,
SetAllPrivacy,
GetProfile,
EditProfile,
SetPersonaName,
GetAliasHistory,
ClearPreviousAliases,
SetNickname,
RemoveNickname,
PostProfileStatus,
SelectPreviousAvatar,
SetupProfile,
GetUserSummaryFromXml,
GetUserSummaryFromProfile,
FetchFullProfile,
ResolveUser,
GetAvatarHistory,
UploadAvatarFromUrl,
EnumerateTokens,
CheckTokenExists,
RevokeTokens,
GetTradeUrl,
GetTradeOffer,
AcceptTradeOffer,
DeclineTradeOffer,
SendTradeOffer,
GetSteamGuardStatus,
EnableTwoFactor,
FinalizeTwoFactor,
DisableTwoFactor,
DeauthorizeDevices,
AddAuthenticator,
FinalizeAuthenticator,
RemoveAuthenticator,
EnableSteamGuardEmail,
DisableSteamGuardEmail,
GetPlayerReports,
AddFreeLicense,
AddSubFreeLicense,
RedeemPoints,
GetHelpRequests,
GetHelpRequestDetail,
GetMatchHistory,
LoggedIn,
GetNotifications,
GetWebApiKey,
ResolveVanityUrl,
RevokeWebApiKey,
}
impl ApiAction {
pub fn is_read_only(&self) -> bool {
match self {
Self::RedeemWalletCode
| Self::ParentalUnlock
| Self::CommentUserReceivedNewGame
| Self::RateUpUserReceivedNewGame
| Self::DeleteCommentUserReceivedNewGame
| Self::PostComment
| Self::DeleteComment
| Self::AcceptConfirmationForObject
| Self::DenyConfirmationForObject
| Self::AddFriend
| Self::RemoveFriend
| Self::AcceptFriendRequest
| Self::IgnoreFriendRequest
| Self::BlockUser
| Self::UnblockUser
| Self::CreateInstantInvite
| Self::FollowUser
| Self::UnfollowUser
| Self::RemoveFriends
| Self::UnfollowUsers
| Self::CancelFriendRequest
| Self::JoinGroup
| Self::LeaveGroup
| Self::PostGroupAnnouncement
| Self::KickGroupMember
| Self::InviteUserToGroup
| Self::InviteUsersToGroup
| Self::AcceptGroupInvite
| Self::IgnoreGroupInvite
| Self::InviteAllFriendsToGroup
| Self::SellItem
| Self::RemoveListing
| Self::TurnItemIntoGems
| Self::CreateBoosterPack
| Self::OpenBoosterPack
| Self::AddPhoneNumber
| Self::ConfirmPhoneCodeForAdd
| Self::ResendPhoneVerificationCode
| Self::SendAccountRecoveryCode
| Self::ConfirmRemovePhoneNumberCode
| Self::SendConfirmation2SteamMobileApp
| Self::SendConfirmation2SteamMobileAppFinal
| Self::SetPrivacySettings
| Self::SetAllPrivacy
| Self::EditProfile
| Self::SetPersonaName
| Self::ClearPreviousAliases
| Self::SetNickname
| Self::RemoveNickname
| Self::PostProfileStatus
| Self::SelectPreviousAvatar
| Self::SetupProfile
| Self::UploadAvatarFromUrl
| Self::RevokeTokens
| Self::AcceptTradeOffer
| Self::DeclineTradeOffer
| Self::SendTradeOffer
| Self::EnableTwoFactor
| Self::FinalizeTwoFactor
| Self::DisableTwoFactor
| Self::DeauthorizeDevices
| Self::AddAuthenticator
| Self::FinalizeAuthenticator
| Self::RemoveAuthenticator
| Self::EnableSteamGuardEmail
| Self::DisableSteamGuardEmail
| Self::AddFreeLicense
| Self::AddSubFreeLicense
| Self::RedeemPoints
| Self::RevokeWebApiKey => false,
Self::GetAccountDetails
| Self::GetSteamWalletBalance
| Self::GetAmountSpentOnSteam
| Self::GetPurchaseHistory
| Self::GetFriendActivity
| Self::GetFriendActivityFull
| Self::GetOwnedApps
| Self::GetOwnedAppsId
| Self::GetOwnedAppsDetail
| Self::GetAppDetail
| Self::FetchCsgoAccountStats
| Self::GetAppList
| Self::SuggestAppList
| Self::QueryAppList
| Self::GetSteamAppVersionInfo
| Self::GetDynamicStoreUserData
| Self::FetchBatchedLoyaltyRewardItems
| Self::GetMyComments
| Self::GetUserComments
| Self::GetConfirmations
| Self::GetAccountEmail
| Self::GetCurrentSteamLogin
| Self::GetFriendsList
| Self::GetFriendsDetails
| Self::GetFriendsDetailsOfUser
| Self::SearchUsers
| Self::GetFollowingList
| Self::GetFollowingListOfUser
| Self::GetMyFriendsIdList
| Self::GetPendingFriendList
| Self::GetFriendsInCommon
| Self::GetGroupMembers
| Self::GetGroupOverview
| Self::GetGroupSteamIdFromVanityUrl
| Self::GetGroupInfoXml
| Self::GetGroupInfoXmlFull
| Self::GetInvitableGroups
| Self::GetInventory
| Self::GetUserInventoryContents
| Self::GetInventoryHistory
| Self::GetPriceOverview
| Self::GetActiveInventories
| Self::GetInventoryTrading
| Self::GetInventoryTradingPartner
| Self::GetFullInventoryHistory
| Self::GetMyListings
| Self::GetMarketHistory
| Self::GetGemValue
| Self::GetBoosterPackCatalog
| Self::GetMarketRestrictions
| Self::GetMarketApps
| Self::GetItemNameid
| Self::GetItemOrdersHistogram
| Self::GetPhoneNumberStatus
| Self::GetRemovePhoneNumberType
| Self::GetPrivacySettings
| Self::GetProfile
| Self::GetAliasHistory
| Self::GetUserSummaryFromXml
| Self::GetUserSummaryFromProfile
| Self::FetchFullProfile
| Self::ResolveUser
| Self::GetAvatarHistory
| Self::EnumerateTokens
| Self::CheckTokenExists
| Self::GetTradeUrl
| Self::GetTradeOffer
| Self::GetSteamGuardStatus
| Self::GetPlayerReports
| Self::GetHelpRequests
| Self::GetHelpRequestDetail
| Self::GetMatchHistory
| Self::LoggedIn
| Self::GetNotifications
| Self::GetWebApiKey
| Self::ResolveVanityUrl => true,
}
}
}
pub trait ActionContext<T> {
fn with_action(self, action: ApiAction) -> Result<T, SteamUserError>;
}
impl<T, E> ActionContext<T> for Result<T, E>
where
SteamUserError: From<E>,
{
fn with_action(self, action: ApiAction) -> Result<T, SteamUserError> {
self.map_err(|e| SteamUserError::ActionFailed { action, source: Box::new(SteamUserError::from(e)) })
}
}