From 86e821c702b7d5074ab78f00830d3fa5d3b03571 Mon Sep 17 00:00:00 2001 From: Kalakoi Date: Wed, 18 Jun 2025 08:30:51 -0400 Subject: [PATCH] Updated random.org objects to allow for proper deserialization. --- osrs-toolbox/APIs/Random/Random.cs | 8 ------- .../APIs/Random/RandomIntegerRequest.cs | 22 ++++++++++--------- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/osrs-toolbox/APIs/Random/Random.cs b/osrs-toolbox/APIs/Random/Random.cs index 0fee2f3..1815be4 100644 --- a/osrs-toolbox/APIs/Random/Random.cs +++ b/osrs-toolbox/APIs/Random/Random.cs @@ -26,18 +26,10 @@ namespace osrs_toolbox replacement = AllowDuplicates } }; - string TestString = string.Empty; - TestString += string.Format("{0}: {1}\n", nameof(Request.jsonrpc), Request.jsonrpc); - TestString += string.Format("{0}: {1}\n", nameof(Request.method), Request.method); string RequestJson = Request.GetJson(); - TestString += string.Format("{0}\n", RequestJson); string ResponseJson = await RestServices.GetPostResponseAsync(new Uri(BaseEndpoint), RequestJson, APIKey).ConfigureAwait(false); - TestString += string.Format("{0}", ResponseJson); - MessageBox.Show(TestString); RandomIntegerRequestResponse response = JsonSerializer.Deserialize(ResponseJson); return response.result.random.data; - //return TestString; - //return ResponseJson; } } } diff --git a/osrs-toolbox/APIs/Random/RandomIntegerRequest.cs b/osrs-toolbox/APIs/Random/RandomIntegerRequest.cs index 91d5e24..a3f2851 100644 --- a/osrs-toolbox/APIs/Random/RandomIntegerRequest.cs +++ b/osrs-toolbox/APIs/Random/RandomIntegerRequest.cs @@ -11,7 +11,9 @@ namespace osrs_toolbox { public class RandomIntegerRequest { + [JsonPropertyName("jsonrpc")] public string jsonrpc { get; set; } = "2.0"; + [JsonPropertyName("method")] public string method { get; set; } = "generateIntegers"; [JsonPropertyName("params")] public RandomIntegerRequestParameters parameters { get; set; } = new(); @@ -34,23 +36,23 @@ namespace osrs_toolbox public class RandomIntegerRequestResponse { - public string jsonrpc; - public RandomIntegerResult result; - public int id; + public string jsonrpc { get; set; } + public RandomIntegerResult result { get; set; } + public long id { get; set; } } public class RandomIntegerResult { - public RandomIntegerData random; - public int bitsUsed; - public int bitsLeft; - public int requestsLeft; - public int advisoryDelay; + public RandomIntegerData random { get; set; } + public int bitsUsed { get; set; } + public int bitsLeft { get; set; } + public int requestsLeft { get; set; } + public int advisoryDelay { get; set; } } public class RandomIntegerData { - public int[] data; - public DateTime completionTime; + public int[] data { get; set; } + public string completionTime { get; set; } } }