From f2b8897ed1344b0b82dfe06850b97d59f8c11d07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Domeradzki?= Date: Sun, 13 Oct 2024 18:36:50 +0200 Subject: [PATCH] Misc --- .../IPC/Controllers/Api/BotController.cs | 56 +++++++++---------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/ArchiSteamFarm/IPC/Controllers/Api/BotController.cs b/ArchiSteamFarm/IPC/Controllers/Api/BotController.cs index 8973a6b5d..d1e321dec 100644 --- a/ArchiSteamFarm/IPC/Controllers/Api/BotController.cs +++ b/ArchiSteamFarm/IPC/Controllers/Api/BotController.cs @@ -74,34 +74,6 @@ public sealed class BotController : ArchiController { return Ok(new GenericResponse>(result)); } - /// - /// Redeems points on given bots. - /// - [Consumes("application/json")] - [HttpPost("{botNames:required}/RedeemPoints/{definitionID:required}")] - [ProducesResponseType>>((int) HttpStatusCode.OK)] - [ProducesResponseType((int) HttpStatusCode.BadRequest)] - public async Task> AddLicensePost(string botNames, uint definitionID) { - ArgumentException.ThrowIfNullOrEmpty(botNames); - ArgumentOutOfRangeException.ThrowIfZero(definitionID); - - HashSet? bots = Bot.GetBots(botNames); - - if ((bots == null) || (bots.Count == 0)) { - return BadRequest(new GenericResponse(false, Strings.FormatBotNotFound(botNames))); - } - - IList results = await Utilities.InParallel(bots.Select(bot => bot.Actions.RedeemPoints(definitionID))).ConfigureAwait(false); - - Dictionary result = new(bots.Count, Bot.BotsComparer); - - foreach (Bot bot in bots) { - result[bot.BotName] = results[result.Count]; - } - - return Ok(new GenericResponse>(result)); - } - /// /// Deletes all files related to given bots. /// @@ -346,6 +318,34 @@ public sealed class BotController : ArchiController { return Ok(new GenericResponse(results.All(static result => result.Success), string.Join(Environment.NewLine, results.Select(static result => result.Message)))); } + /// + /// Redeems points on given bots. + /// + [Consumes("application/json")] + [HttpPost("{botNames:required}/RedeemPoints/{definitionID:required}")] + [ProducesResponseType>>((int) HttpStatusCode.OK)] + [ProducesResponseType((int) HttpStatusCode.BadRequest)] + public async Task> RedeemPointsPost(string botNames, uint definitionID) { + ArgumentException.ThrowIfNullOrEmpty(botNames); + ArgumentOutOfRangeException.ThrowIfZero(definitionID); + + HashSet? bots = Bot.GetBots(botNames); + + if ((bots == null) || (bots.Count == 0)) { + return BadRequest(new GenericResponse(false, Strings.FormatBotNotFound(botNames))); + } + + IList results = await Utilities.InParallel(bots.Select(bot => bot.Actions.RedeemPoints(definitionID))).ConfigureAwait(false); + + Dictionary result = new(bots.Count, Bot.BotsComparer); + + foreach (Bot bot in bots) { + result[bot.BotName] = results[result.Count]; + } + + return Ok(new GenericResponse>(result)); + } + /// /// Redeems cd-keys on given bot. ///