Updated random.org objects to allow for proper deserialization.
This commit is contained in:
@@ -26,18 +26,10 @@ namespace osrs_toolbox
|
|||||||
replacement = AllowDuplicates
|
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();
|
string RequestJson = Request.GetJson();
|
||||||
TestString += string.Format("{0}\n", RequestJson);
|
|
||||||
string ResponseJson = await RestServices.GetPostResponseAsync(new Uri(BaseEndpoint), RequestJson, APIKey).ConfigureAwait(false);
|
string ResponseJson = await RestServices.GetPostResponseAsync(new Uri(BaseEndpoint), RequestJson, APIKey).ConfigureAwait(false);
|
||||||
TestString += string.Format("{0}", ResponseJson);
|
|
||||||
MessageBox.Show(TestString);
|
|
||||||
RandomIntegerRequestResponse response = JsonSerializer.Deserialize<RandomIntegerRequestResponse>(ResponseJson);
|
RandomIntegerRequestResponse response = JsonSerializer.Deserialize<RandomIntegerRequestResponse>(ResponseJson);
|
||||||
return response.result.random.data;
|
return response.result.random.data;
|
||||||
//return TestString;
|
|
||||||
//return ResponseJson;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -11,7 +11,9 @@ namespace osrs_toolbox
|
|||||||
{
|
{
|
||||||
public class RandomIntegerRequest
|
public class RandomIntegerRequest
|
||||||
{
|
{
|
||||||
|
[JsonPropertyName("jsonrpc")]
|
||||||
public string jsonrpc { get; set; } = "2.0";
|
public string jsonrpc { get; set; } = "2.0";
|
||||||
|
[JsonPropertyName("method")]
|
||||||
public string method { get; set; } = "generateIntegers";
|
public string method { get; set; } = "generateIntegers";
|
||||||
[JsonPropertyName("params")]
|
[JsonPropertyName("params")]
|
||||||
public RandomIntegerRequestParameters parameters { get; set; } = new();
|
public RandomIntegerRequestParameters parameters { get; set; } = new();
|
||||||
@@ -34,23 +36,23 @@ namespace osrs_toolbox
|
|||||||
|
|
||||||
public class RandomIntegerRequestResponse
|
public class RandomIntegerRequestResponse
|
||||||
{
|
{
|
||||||
public string jsonrpc;
|
public string jsonrpc { get; set; }
|
||||||
public RandomIntegerResult result;
|
public RandomIntegerResult result { get; set; }
|
||||||
public int id;
|
public long id { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class RandomIntegerResult
|
public class RandomIntegerResult
|
||||||
{
|
{
|
||||||
public RandomIntegerData random;
|
public RandomIntegerData random { get; set; }
|
||||||
public int bitsUsed;
|
public int bitsUsed { get; set; }
|
||||||
public int bitsLeft;
|
public int bitsLeft { get; set; }
|
||||||
public int requestsLeft;
|
public int requestsLeft { get; set; }
|
||||||
public int advisoryDelay;
|
public int advisoryDelay { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class RandomIntegerData
|
public class RandomIntegerData
|
||||||
{
|
{
|
||||||
public int[] data;
|
public int[] data { get; set; }
|
||||||
public DateTime completionTime;
|
public string completionTime { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user