From b06280910e76e87f66ab857698c622e774453a50 Mon Sep 17 00:00:00 2001 From: Kalakoi Date: Wed, 21 May 2025 14:28:07 -0400 Subject: [PATCH] Added basic Wise Old Man API functionality for getting player, group, and competition information. --- osrs-toolbox/APIs/WiseOldMan/WiseOldMan.cs | 54 ++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 osrs-toolbox/APIs/WiseOldMan/WiseOldMan.cs diff --git a/osrs-toolbox/APIs/WiseOldMan/WiseOldMan.cs b/osrs-toolbox/APIs/WiseOldMan/WiseOldMan.cs new file mode 100644 index 0000000..7a9b04c --- /dev/null +++ b/osrs-toolbox/APIs/WiseOldMan/WiseOldMan.cs @@ -0,0 +1,54 @@ +using System.Text.Json; +using System.Windows.Media.Imaging; + +namespace osrs_toolbox +{ + public static class WiseOldMan + { + private static string CompetitionEndpoint = @"https://api.wiseoldman.net/v2/competitions/"; + private static string GroupEndpoint = @"https://api.wiseoldman.net/v2/groups/"; + private static string PlayerEndpoint = @"https://api.wiseoldman.net/v2/players/"; + + public static Player GetPlayer(string Username) + { + string res = RestServices.GetResponse(new Uri(PlayerEndpoint + Username), string.Empty); + Player p = JsonSerializer.Deserialize(res); + return p; + } + + public static async Task GetPlayerAsync(string Username) + { + string res = await RestServices.GetResponseAsync(new Uri(PlayerEndpoint + Username), string.Empty).ConfigureAwait(false); + Player p = JsonSerializer.Deserialize(res); + return p; + } + + public static Group GetGroup(int ID) + { + string res = RestServices.GetResponse(new Uri(GroupEndpoint + ID.ToString()), string.Empty); + Group g = JsonSerializer.Deserialize(res); + return g; + } + + public static async Task GetGroupAsync(int ID) + { + string res = await RestServices.GetResponseAsync(new Uri(GroupEndpoint + ID.ToString()), string.Empty).ConfigureAwait(false); + Group g = JsonSerializer.Deserialize(res); + return g; + } + + public static Competition GetCompetition(int ID) + { + string res = RestServices.GetResponse(new Uri(CompetitionEndpoint + ID.ToString()), string.Empty); + Competition c = JsonSerializer.Deserialize(res); + return c; + } + + public static async Task GetCompetitionAsync(int ID) + { + string res = await RestServices.GetResponseAsync(new Uri(CompetitionEndpoint + ID.ToString()), string.Empty).ConfigureAwait(false); + Competition c = JsonSerializer.Deserialize(res); + return c; + } + } +} \ No newline at end of file