diff --git a/ArchiSteamFarm/Steam/Data/InventoryResponse.cs b/ArchiSteamFarm/Steam/Data/InventoryResponse.cs index 7ca733a54..b2b865e03 100644 --- a/ArchiSteamFarm/Steam/Data/InventoryResponse.cs +++ b/ArchiSteamFarm/Steam/Data/InventoryResponse.cs @@ -33,7 +33,7 @@ using Newtonsoft.Json.Linq; namespace ArchiSteamFarm.Steam.Data; [SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] -internal sealed class InventoryResponse : ResultResponse { +internal sealed class InventoryResponse : OptionalResultResponse { [JsonProperty(PropertyName = "assets", Required = Required.DisallowNull)] internal readonly ImmutableHashSet Assets = ImmutableHashSet.Empty; diff --git a/ArchiSteamFarm/Steam/Data/OptionalResultResponse.cs b/ArchiSteamFarm/Steam/Data/OptionalResultResponse.cs new file mode 100644 index 000000000..08037b40f --- /dev/null +++ b/ArchiSteamFarm/Steam/Data/OptionalResultResponse.cs @@ -0,0 +1,35 @@ +// _ _ _ ____ _ _____ +// / \ _ __ ___ | |__ (_)/ ___| | |_ ___ __ _ _ __ ___ | ___|__ _ _ __ _ __ ___ +// / _ \ | '__|/ __|| '_ \ | |\___ \ | __|/ _ \ / _` || '_ ` _ \ | |_ / _` || '__|| '_ ` _ \ +// / ___ \ | | | (__ | | | || | ___) || |_| __/| (_| || | | | | || _|| (_| || | | | | | | | +// /_/ \_\|_| \___||_| |_||_||____/ \__|\___| \__,_||_| |_| |_||_| \__,_||_| |_| |_| |_| +// | +// Copyright 2015-2022 Ɓukasz "JustArchi" Domeradzki +// Contact: JustArchi@JustArchi.net +// | +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// | +// http://www.apache.org/licenses/LICENSE-2.0 +// | +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using JetBrains.Annotations; +using Newtonsoft.Json; +using SteamKit2; + +namespace ArchiSteamFarm.Steam.Data; + +[PublicAPI] +public class OptionalResultResponse { + [JsonProperty(PropertyName = "success", Required = Required.DisallowNull)] + public EResult? Result { get; private set; } + + [JsonConstructor] + protected OptionalResultResponse() { } +} diff --git a/ArchiSteamFarm/Steam/Data/ResultResponse.cs b/ArchiSteamFarm/Steam/Data/ResultResponse.cs index 277b0cc51..67edd56e0 100644 --- a/ArchiSteamFarm/Steam/Data/ResultResponse.cs +++ b/ArchiSteamFarm/Steam/Data/ResultResponse.cs @@ -19,7 +19,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -using System.Diagnostics.CodeAnalysis; using JetBrains.Annotations; using Newtonsoft.Json; using SteamKit2; @@ -27,7 +26,6 @@ using SteamKit2; namespace ArchiSteamFarm.Steam.Data; [PublicAPI] -[SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] public class ResultResponse { [JsonProperty(PropertyName = "success", Required = Required.Always)] public EResult Result { get; private set; } diff --git a/ArchiSteamFarm/Steam/Integration/ArchiWebHandler.cs b/ArchiSteamFarm/Steam/Integration/ArchiWebHandler.cs index cee42f07c..7e6248d7d 100644 --- a/ArchiSteamFarm/Steam/Integration/ArchiWebHandler.cs +++ b/ArchiSteamFarm/Steam/Integration/ArchiWebHandler.cs @@ -208,8 +208,8 @@ public sealed class ArchiWebHandler : IDisposable { throw new HttpRequestException(string.Format(CultureInfo.CurrentCulture, Strings.ErrorObjectIsNull, nameof(response))); } - if (response.Content.Result != EResult.OK) { - throw new HttpRequestException(!string.IsNullOrEmpty(response.Content.Error) ? string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, response.Content.Error) : Strings.WarningFailed); + if (response.Content.Result is not EResult.OK) { + throw new HttpRequestException(!string.IsNullOrEmpty(response.Content.Error) ? string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, response.Content.Error) : response.Content.Result.HasValue ? string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, response.Content.Result) : Strings.WarningFailed); } if (response.Content.TotalInventoryCount == 0) {