Rewrite ASF inventory fetching into new endpoint, #646

This commit is contained in:
JustArchi
2017-09-17 18:01:17 +02:00
parent c37123e66b
commit 035b70458e
8 changed files with 352 additions and 376 deletions

View File

@@ -31,7 +31,6 @@ using System.Xml;
using ArchiSteamFarm.Localization;
using HtmlAgilityPack;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace ArchiSteamFarm {
internal sealed class WebBrowser : IDisposable {
@@ -133,26 +132,6 @@ namespace ArchiSteamFarm {
return null;
}
internal async Task<JObject> UrlGetToJObjectRetry(string request, string referer = null) {
if (string.IsNullOrEmpty(request)) {
ArchiLogger.LogNullError(nameof(request));
return null;
}
JObject result = null;
for (byte i = 0; (i < MaxTries) && (result == null); i++) {
result = await UrlGetToJObject(request, referer).ConfigureAwait(false);
}
if (result != null) {
return result;
}
ArchiLogger.LogGenericWarning(string.Format(Strings.ErrorRequestFailedTooManyTimes, MaxTries));
ArchiLogger.LogGenericDebug(string.Format(Strings.ErrorFailingRequest, request));
return null;
}
internal async Task<T> UrlGetToJsonResultRetry<T>(string request, string referer = null) {
if (string.IsNullOrEmpty(request)) {
ArchiLogger.LogNullError(nameof(request));
@@ -362,29 +341,6 @@ namespace ArchiSteamFarm {
return !string.IsNullOrEmpty(content) ? StringToHtmlDocument(content) : null;
}
private async Task<JObject> UrlGetToJObject(string request, string referer = null) {
if (string.IsNullOrEmpty(request)) {
ArchiLogger.LogNullError(nameof(request));
return null;
}
string json = await UrlGetToContent(request, referer).ConfigureAwait(false);
if (string.IsNullOrEmpty(json)) {
return null;
}
JObject jObject;
try {
jObject = JObject.Parse(json);
} catch (JsonException e) {
ArchiLogger.LogGenericException(e);
return null;
}
return jObject;
}
private async Task<HttpResponseMessage> UrlGetToResponse(string request, string referer = null) {
if (string.IsNullOrEmpty(request)) {
ArchiLogger.LogNullError(nameof(request));