STD: Make data field in response optional

Data field is not included in case of non-200 status codes.
This commit is contained in:
JustArchi 2021-02-22 17:56:03 +01:00
parent 34fbb9f86d
commit e836cb66e4
2 changed files with 9 additions and 3 deletions

View file

@ -25,8 +25,8 @@ using Newtonsoft.Json;
namespace ArchiSteamFarm.OfficialPlugins.SteamTokenDumper {
[SuppressMessage("ReSharper", "ClassCannotBeInstantiated")]
internal sealed class ResponseData {
[JsonProperty(PropertyName = "data", Required = Required.Always)]
internal readonly InternalData Data = new();
[JsonProperty(PropertyName = "data", Required = Required.DisallowNull)]
internal readonly InternalData? Data;
#pragma warning disable CS0649
[JsonProperty(PropertyName = "success", Required = Required.Always)]
@ -53,7 +53,7 @@ namespace ArchiSteamFarm.OfficialPlugins.SteamTokenDumper {
#pragma warning restore CS0649
[JsonConstructor]
internal InternalData() { }
private InternalData() { }
}
}
}

View file

@ -488,6 +488,12 @@ namespace ArchiSteamFarm.OfficialPlugins.SteamTokenDumper {
return;
}
if (response.Content.Data == null) {
ASF.ArchiLogger.LogGenericError(string.Format(Strings.ErrorIsInvalid), nameof(response.Content.Data));
return;
}
ASF.ArchiLogger.LogGenericInfo($"Data successfully submitted. Newly registered apps/subs/depots: {response.Content.Data.NewAppsCount}/{response.Content.Data.NewSubsCount}/{response.Content.Data.NewDepotsCount}.");
GlobalCache.UpdateSubmittedData(appTokens, packageTokens, depotKeys);