From d1918203170b3d5ba8e6c295c64972f59a6d0597 Mon Sep 17 00:00:00 2001 From: JustArchi Date: Wed, 24 Jun 2020 20:49:55 +0200 Subject: [PATCH] Expose STDP global config schema in swagger and tag it --- .../GlobalConfigExtension.cs | 32 +++++++++++++++++ .../SharedInfo.cs | 1 - .../SteamTokenDumperController.cs | 35 +++++++++++++++++++ .../SteamTokenDumperPlugin.cs | 3 +- 4 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/GlobalConfigExtension.cs create mode 100644 ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/SteamTokenDumperController.cs diff --git a/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/GlobalConfigExtension.cs b/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/GlobalConfigExtension.cs new file mode 100644 index 000000000..1891ad173 --- /dev/null +++ b/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/GlobalConfigExtension.cs @@ -0,0 +1,32 @@ +// _ _ _ ____ _ _____ +// / \ _ __ ___ | |__ (_)/ ___| | |_ ___ __ _ _ __ ___ | ___|__ _ _ __ _ __ ___ +// / _ \ | '__|/ __|| '_ \ | |\___ \ | __|/ _ \ / _` || '_ ` _ \ | |_ / _` || '__|| '_ ` _ \ +// / ___ \ | | | (__ | | | || | ___) || |_| __/| (_| || | | | | || _|| (_| || | | | | | | | +// /_/ \_\|_| \___||_| |_||_||____/ \__|\___| \__,_||_| |_| |_||_| \__,_||_| |_| |_| |_| +// | +// Copyright 2015-2020 Ł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 Newtonsoft.Json; + +namespace ArchiSteamFarm.OfficialPlugins.SteamTokenDumper { + public sealed class GlobalConfigExtension { + [JsonProperty] + public readonly bool SteamTokenDumperPluginEnabled; + + [JsonConstructor] + internal GlobalConfigExtension() { } + } +} diff --git a/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/SharedInfo.cs b/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/SharedInfo.cs index 5a72de768..6e117f015 100644 --- a/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/SharedInfo.cs +++ b/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/SharedInfo.cs @@ -23,7 +23,6 @@ namespace ArchiSteamFarm.OfficialPlugins.SteamTokenDumper { internal static class SharedInfo { internal const byte ApiVersion = 1; internal const byte AppInfosPerSingleRequest = byte.MaxValue; - internal const string ConfigurationPropertyEnabled = nameof(SteamTokenDumperPlugin) + "Enabled"; internal const byte MaximumHoursBetweenRefresh = 8; // Per single bot account, makes sense to be 2 or 3 times less than MinimumHoursBetweenUploads internal const byte MaximumMinutesBeforeFirstUpload = 60; // Must be greater or equal to MinimumMinutesBeforeFirstUpload internal const byte MinimumHoursBetweenUploads = 24; diff --git a/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/SteamTokenDumperController.cs b/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/SteamTokenDumperController.cs new file mode 100644 index 000000000..681fc5bab --- /dev/null +++ b/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/SteamTokenDumperController.cs @@ -0,0 +1,35 @@ +// _ _ _ ____ _ _____ +// / \ _ __ ___ | |__ (_)/ ___| | |_ ___ __ _ _ __ ___ | ___|__ _ _ __ _ __ ___ +// / _ \ | '__|/ __|| '_ \ | |\___ \ | __|/ _ \ / _` || '_ ` _ \ | |_ / _` || '__|| '_ ` _ \ +// / ___ \ | | | (__ | | | || | ___) || |_| __/| (_| || | | | | || _|| (_| || | | | | | | | +// /_/ \_\|_| \___||_| |_||_||____/ \__|\___| \__,_||_| |_| |_||_| \__,_||_| |_| |_| |_| +// | +// Copyright 2015-2020 Ł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 System.Net; +using ArchiSteamFarm.IPC.Controllers.Api; +using Microsoft.AspNetCore.Mvc; +using Swashbuckle.AspNetCore.Annotations; + +namespace ArchiSteamFarm.OfficialPlugins.SteamTokenDumper { + [Route("Api/SteamTokenDumperPlugin")] + public sealed class SteamTokenDumperController : ArchiController { + [HttpGet(nameof(GlobalConfigExtension))] + [ProducesResponseType(typeof(GlobalConfigExtension), (int) HttpStatusCode.OK)] + [SwaggerOperation(Tags = new[] { nameof(GlobalConfigExtension) })] + public ActionResult Get() => Ok(new GlobalConfigExtension()); + } +} diff --git a/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/SteamTokenDumperPlugin.cs b/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/SteamTokenDumperPlugin.cs index fcabe1bbc..420adf3cd 100644 --- a/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/SteamTokenDumperPlugin.cs +++ b/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/SteamTokenDumperPlugin.cs @@ -43,6 +43,7 @@ namespace ArchiSteamFarm.OfficialPlugins.SteamTokenDumper { private static readonly Timer SubmissionTimer = new Timer(async e => await SubmitData().ConfigureAwait(false)); private static GlobalCache GlobalCache; + private static bool IsEnabled; public override string Name => nameof(SteamTokenDumperPlugin); @@ -63,7 +64,7 @@ namespace ArchiSteamFarm.OfficialPlugins.SteamTokenDumper { if (additionalConfigProperties != null) { foreach ((string configProperty, JToken configValue) in additionalConfigProperties) { try { - if (configProperty == SharedInfo.ConfigurationPropertyEnabled) { + if (configProperty == nameof(GlobalConfigExtension.SteamTokenDumperPluginEnabled)) { enabled = configValue.Value(); } } catch (Exception e) {