Add support for steam wallet keys, #239

This commit is contained in:
JustArchi
2016-10-12 22:56:19 +02:00
parent e7cda0f472
commit f7d822be99
4 changed files with 45 additions and 3 deletions

View File

@@ -554,6 +554,25 @@ namespace ArchiSteamFarm {
return null;
}
internal async Task<ArchiHandler.PurchaseResponseCallback.EPurchaseResult> RedeemWalletKey(string key) {
if (string.IsNullOrEmpty(key)) {
Logging.LogNullError(nameof(key), Bot.BotName);
return ArchiHandler.PurchaseResponseCallback.EPurchaseResult.Unknown;
}
if (!await RefreshSessionIfNeeded().ConfigureAwait(false)) {
return ArchiHandler.PurchaseResponseCallback.EPurchaseResult.Timeout;
}
string request = SteamStoreURL + "/account/validatewalletcode";
Dictionary<string, string> data = new Dictionary<string, string>(1) {
{ "wallet_code", key }
};
Steam.RedeemWalletResponse response = await WebBrowser.UrlPostToJsonResultRetry<Steam.RedeemWalletResponse>(request, data).ConfigureAwait(false);
return response?.PurchaseResult ?? ArchiHandler.PurchaseResponseCallback.EPurchaseResult.Timeout;
}
internal HashSet<Steam.TradeOffer> GetActiveTradeOffers() {
if (string.IsNullOrEmpty(Bot.BotConfig.SteamApiKey)) {
Logging.LogNullError(nameof(Bot.BotConfig.SteamApiKey), Bot.BotName);