diff --git a/osrs-toolbox/APIs/RestServices.cs b/osrs-toolbox/APIs/RestServices.cs new file mode 100644 index 0000000..4d37f3e --- /dev/null +++ b/osrs-toolbox/APIs/RestServices.cs @@ -0,0 +1,150 @@ +using System.IO; +using System.Net.Http.Headers; +using System.Net.Http; +using System.Net; +using System.Text; + +namespace osrs_toolbox +{ + /// + /// Provides easy access to GET and POST functionality for REST services. + /// + internal static class RestServices + { + /// + /// Sends GET request to REST service and returns response asynchronously. + /// + /// Address to send request to. + /// API key to use with the request. + /// JSON data as string. + internal static async Task GetResponseAsync(Uri uri, string APIKey) + { + //Create client to send GET request + using (HttpClient client = new HttpClient()) + { + //Add request headers + client.DefaultRequestHeaders.Add("user-agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome / 58.0.3029.110 Safari / 537.36"); + client.DefaultRequestHeaders.Add("X-Authorization", APIKey); + //Send request and await response + string response = await client.GetStringAsync(uri).ConfigureAwait(false); + return response; + } + } + + /// + /// Sends GET request to REST service and returns response asynchronously. + /// + /// Address to send request to. + /// JSON data as string. + internal static async Task GetResponseAsync(Uri uri) + { + //Create client to send GET request + using (HttpClient client = new HttpClient()) + { + //Add request headers + client.DefaultRequestHeaders.Add("user-agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome / 58.0.3029.110 Safari / 537.36"); + //Send request and await response + string response = await client.GetStringAsync(uri).ConfigureAwait(false); + return response; + } + } + + /// + /// Sends GET request to REST service and returns response. + /// + /// Address to send request to. + /// API key to use with the request. + /// JSON data as string. + internal static string GetResponse(Uri uri, string APIKey) + { + //Create client to send GET request + using (WebClient client = new WebClient()) + { + //Add request headers + client.Headers.Add(string.Format("X-Authorization: {0}", APIKey)); + client.Headers.Add(HttpRequestHeader.Accept, "application/json"); + client.Headers.Add(HttpRequestHeader.AcceptLanguage, "en-US"); + //Send request and await response + using (Stream ReqStream = client.OpenRead(uri)) + using (StreamReader Reader = new StreamReader(ReqStream)) + { + string response = Reader.ReadToEnd(); + return response; + } + } + } + + /// + /// Sends GET request to REST service and returns response. + /// + /// Address to send request to. + /// JSON data as string. + internal static string GetResponse(Uri uri) + { + //Create client to send GET request + using (WebClient client = new WebClient()) + { + //Add request headers + client.Headers.Add(HttpRequestHeader.Accept, "application/json"); + client.Headers.Add(HttpRequestHeader.AcceptLanguage, "en-US"); + //Send request and await response + using (Stream ReqStream = client.OpenRead(uri)) + using (StreamReader Reader = new StreamReader(ReqStream)) + { + string response = Reader.ReadToEnd(); + return response; + } + } + } + + /// + /// Sends POST request to REST service with JSON data and returns response asynchronously. + /// + /// Web address to send request. + /// JSON data to send with request. + /// API key to use with the request. + /// JSON data as string. + internal static async Task GetPostResponseAsync(Uri uri, string Data, string APIKey) + { + //Create Client to send and receive data from REST service + using (HttpClient client = new HttpClient()) + { + //Add headers for request + client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); + client.DefaultRequestHeaders.Add("user-agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome / 58.0.3029.110 Safari / 537.36"); + client.DefaultRequestHeaders.Add("X-Authorization", APIKey); + client.DefaultRequestHeaders.Host = uri.Host; + //Create content to send from JSON string + HttpContent content = new StringContent(Data, Encoding.UTF8, @"application/json"); + //Send POST request and await response + HttpResponseMessage response = await client.PostAsync(uri, content).ConfigureAwait(false); + response.EnsureSuccessStatusCode(); + //Return response JSON as string + return await response.Content.ReadAsStringAsync().ConfigureAwait(false); + } + } + + /// + /// Sends POST request to REST service with JSON data and returns response. + /// + /// Web address to send request. + /// JSON data to send with request. + /// API key to use with the request. + /// JSON data as string. + internal static string GetPostResponse(Uri uri, string Data, string APIKey) + { + //Create client to send POST request + using (WebClient client = new WebClient()) + { + //Add request headers + client.Headers.Add(string.Format("X-Authorization: {0}", APIKey)); + client.Headers.Add(HttpRequestHeader.Accept, "application/json"); + client.Headers.Add(HttpRequestHeader.AcceptLanguage, "en-US"); + client.Headers.Add(HttpRequestHeader.ContentType, "application/x-www-form-urlencoded"); + //Send POST request and await response + string response = client.UploadString(uri, Data); + return response; + } + } + } +} diff --git a/osrs-toolbox/APIs/WiseOldMan/Competition/Competition.cs b/osrs-toolbox/APIs/WiseOldMan/Competition/Competition.cs new file mode 100644 index 0000000..e06bf14 --- /dev/null +++ b/osrs-toolbox/APIs/WiseOldMan/Competition/Competition.cs @@ -0,0 +1,20 @@ +namespace osrs_toolbox +{ + public class Competition + { + public int id { get; set; } + public string title { get; set; } + public string metric { get; set; } + public string type { get; set; } + public DateTime startsAt { get; set; } + public DateTime endsAt { get; set; } + public int groupId { get; set; } + public int score { get; set; } + public bool visible { get; set; } + public DateTime createdAt { get; set; } + public DateTime updatedAt { get; set; } + public Group group { get; set; } + public int participantCount { get; set; } + public CompetitionParticipation[] participations { get; set; } + } +} \ No newline at end of file diff --git a/osrs-toolbox/APIs/WiseOldMan/Competition/CompetitionParticipation.cs b/osrs-toolbox/APIs/WiseOldMan/Competition/CompetitionParticipation.cs new file mode 100644 index 0000000..d70581d --- /dev/null +++ b/osrs-toolbox/APIs/WiseOldMan/Competition/CompetitionParticipation.cs @@ -0,0 +1,14 @@ +namespace osrs_toolbox +{ + public class CompetitionParticipation + { + public int playerId { get; set; } + public int competitionId { get; set; } + public string? teamName { get; set; } + public DateTime createdAt { get; set; } + public DateTime updatedAt { get; set; } + public Player player { get; set; } + public ParticipationInfo progress { get; set; } + public ParticipationInfo levels { get; set; } + } +} \ No newline at end of file diff --git a/osrs-toolbox/APIs/WiseOldMan/Competition/ParticipationInfo.cs b/osrs-toolbox/APIs/WiseOldMan/Competition/ParticipationInfo.cs new file mode 100644 index 0000000..af1aab6 --- /dev/null +++ b/osrs-toolbox/APIs/WiseOldMan/Competition/ParticipationInfo.cs @@ -0,0 +1,9 @@ +namespace osrs_toolbox +{ + public class ParticipationInfo + { + public int gained { get; set; } + public int start { get; set; } + public int end { get; set; } + } +} diff --git a/osrs-toolbox/APIs/WiseOldMan/Group/Group.cs b/osrs-toolbox/APIs/WiseOldMan/Group/Group.cs new file mode 100644 index 0000000..686e04d --- /dev/null +++ b/osrs-toolbox/APIs/WiseOldMan/Group/Group.cs @@ -0,0 +1,23 @@ +namespace osrs_toolbox +{ + public class Group + { + public int id { get; set; } + public string name { get; set; } + public string clanChat { get; set; } + public string description { get; set; } + public int homeworld { get; set; } + public bool verified { get; set; } + public bool patron { get; set; } + public bool visible { get; set; } + public object profileImage { get; set; } + public object bannerImage { get; set; } + public int score { get; set; } + public DateTime createdAt { get; set; } + public DateTime updatedAt { get; set; } + public GroupMembership[]? memberships { get; set; } + public GroupLinks? socialLinks { get; set; } + public object[]? roleOrders { get; set; } + public int memberCount { get; set; } + } +} diff --git a/osrs-toolbox/APIs/WiseOldMan/Group/GroupLinks.cs b/osrs-toolbox/APIs/WiseOldMan/Group/GroupLinks.cs new file mode 100644 index 0000000..a2e203a --- /dev/null +++ b/osrs-toolbox/APIs/WiseOldMan/Group/GroupLinks.cs @@ -0,0 +1,11 @@ +namespace osrs_toolbox +{ + public class GroupLinks + { + public string website { get; set; } + public string discord { get; set; } + public string twitter { get; set; } + public string youtube { get; set; } + public string twitch { get; set; } + } +} diff --git a/osrs-toolbox/APIs/WiseOldMan/Group/GroupMembership.cs b/osrs-toolbox/APIs/WiseOldMan/Group/GroupMembership.cs new file mode 100644 index 0000000..ff09cab --- /dev/null +++ b/osrs-toolbox/APIs/WiseOldMan/Group/GroupMembership.cs @@ -0,0 +1,12 @@ +namespace osrs_toolbox +{ + public class GroupMembership + { + public int playerId { get; set; } + public int groupId { get; set; } + public string role { get; set; } + public DateTime createdAt { get; set; } + public DateTime updatedAt { get; set; } + public Player player { get; set; } + } +} \ No newline at end of file diff --git a/osrs-toolbox/APIs/WiseOldMan/Player/ActivityData.cs b/osrs-toolbox/APIs/WiseOldMan/Player/ActivityData.cs new file mode 100644 index 0000000..9aba0aa --- /dev/null +++ b/osrs-toolbox/APIs/WiseOldMan/Player/ActivityData.cs @@ -0,0 +1,9 @@ +namespace osrs_toolbox +{ + public class ActivityData + { + public string metric { get; set; } + public int score { get; set; } + public int rank { get; set; } + } +} diff --git a/osrs-toolbox/APIs/WiseOldMan/Player/BossData.cs b/osrs-toolbox/APIs/WiseOldMan/Player/BossData.cs new file mode 100644 index 0000000..6879b1f --- /dev/null +++ b/osrs-toolbox/APIs/WiseOldMan/Player/BossData.cs @@ -0,0 +1,10 @@ +namespace osrs_toolbox +{ + public class BossData + { + public string metric { get; set; } + public int kills { get; set; } + public int rank { get; set; } + public double ehb { get; set; } + } +} diff --git a/osrs-toolbox/APIs/WiseOldMan/Player/ComputedData.cs b/osrs-toolbox/APIs/WiseOldMan/Player/ComputedData.cs new file mode 100644 index 0000000..f3a5703 --- /dev/null +++ b/osrs-toolbox/APIs/WiseOldMan/Player/ComputedData.cs @@ -0,0 +1,9 @@ +namespace osrs_toolbox +{ + public class ComputedData + { + public string metric { get; set; } + public double value { get; set; } + public int rank { get; set; } + } +} diff --git a/osrs-toolbox/APIs/WiseOldMan/Player/Player.cs b/osrs-toolbox/APIs/WiseOldMan/Player/Player.cs new file mode 100644 index 0000000..62934bd --- /dev/null +++ b/osrs-toolbox/APIs/WiseOldMan/Player/Player.cs @@ -0,0 +1,27 @@ +namespace osrs_toolbox +{ + public class Player + { + public int id { get; set; } + public string username { get; set; } + public string displayName { get; set; } + public string type { get; set; } + public string build { get; set; } + public string status { get; set; } + public string country { get; set; } + public bool patron { get; set; } + public int exp { get; set; } + public double ehp { get; set; } + public double ehb { get; set; } + public double ttm { get; set; } + public double tt200m { get; set; } + public string registeredAt { get; set; } + public string updatedAt { get; set; } + public string lastChangedAt { get; set; } + public string lastImportedAt { get; set; } + public Snapshot? latestSnapshot { get; set; } + public string[]? annotations { get; set; } + public int? combatLevel { get; set; } + public object? archive { get; set; } + } +} diff --git a/osrs-toolbox/APIs/WiseOldMan/Player/PlayerActivities.cs b/osrs-toolbox/APIs/WiseOldMan/Player/PlayerActivities.cs new file mode 100644 index 0000000..3632ed0 --- /dev/null +++ b/osrs-toolbox/APIs/WiseOldMan/Player/PlayerActivities.cs @@ -0,0 +1,22 @@ +namespace osrs_toolbox +{ + public class PlayerActivities + { + public ActivityData league_points { get; set; } + public ActivityData bounty_hunter_hunter { get; set; } + public ActivityData bounty_hunter_rogue { get; set; } + public ActivityData clue_scrolls_all { get; set; } + public ActivityData clue_scrolls_beginner { get; set; } + public ActivityData clue_scrolls_easy { get; set; } + public ActivityData clue_scrolls_medium { get; set; } + public ActivityData clue_scrolls_hard { get; set; } + public ActivityData clue_scrolls_elite { get; set; } + public ActivityData clue_scrolls_master { get; set; } + public ActivityData last_man_standing { get; set; } + public ActivityData pvp_arena { get; set; } + public ActivityData soul_wars_zeal { get; set; } + public ActivityData guardians_of_the_rift { get; set; } + public ActivityData colosseum_glory { get; set; } + public ActivityData collections_logged { get; set; } + } +} diff --git a/osrs-toolbox/APIs/WiseOldMan/Player/PlayerBosses.cs b/osrs-toolbox/APIs/WiseOldMan/Player/PlayerBosses.cs new file mode 100644 index 0000000..65565a3 --- /dev/null +++ b/osrs-toolbox/APIs/WiseOldMan/Player/PlayerBosses.cs @@ -0,0 +1,72 @@ +namespace osrs_toolbox +{ + public class PlayerBosses + { + public BossData abyssal_sire { get; set; } + public BossData alchemical_hydra { get; set; } + public BossData amoxliatl { get; set; } + public BossData araxxor { get; set; } + public BossData artio { get; set; } + public BossData barrows_chests { get; set; } + public BossData bryophyta { get; set; } + public BossData callisto { get; set; } + public BossData calvarion { get; set; } + public BossData cerberus { get; set; } + public BossData chambers_of_xeric { get; set; } + public BossData chambers_of_xeric_challenge_mode { get; set; } + public BossData chaos_elemental { get; set; } + public BossData chaos_fanatic { get; set; } + public BossData commander_zilyana { get; set; } + public BossData corporeal_beast { get; set; } + public BossData crazy_archaeologist { get; set; } + public BossData dagannoth_prime { get; set; } + public BossData dagannoth_rex { get; set; } + public BossData dagannoth_supreme { get; set; } + public BossData deranged_archaeologist { get; set; } + public BossData duke_sucellus { get; set; } + public BossData general_graardor { get; set; } + public BossData giant_mole { get; set; } + public BossData grotesque_guardians { get; set; } + public BossData hespori { get; set; } + public BossData kalphite_queen { get; set; } + public BossData king_black_dragon { get; set; } + public BossData kraken { get; set; } + public BossData kreearra { get; set; } + public BossData kril_tsutsaroth { get; set; } + public BossData lunar_chests { get; set; } + public BossData mimic { get; set; } + public BossData nex { get; set; } + public BossData nightmare { get; set; } + public BossData phosanis_nightmare { get; set; } + public BossData obor { get; set; } + public BossData phantom_muspah { get; set; } + public BossData sarachnis { get; set; } + public BossData scorpia { get; set; } + public BossData scurrius { get; set; } + public BossData skotizo { get; set; } + public BossData sol_heredit { get; set; } + public BossData spindel { get; set; } + public BossData tempoross { get; set; } + public BossData the_gauntlet { get; set; } + public BossData the_corrupted_gauntlet { get; set; } + public BossData the_hueycoatl { get; set; } + public BossData the_leviathan { get; set; } + public BossData the_royal_titans { get; set; } + public BossData the_whisperer { get; set; } + public BossData theatre_of_blood { get; set; } + public BossData theatre_of_blood_hard_mode { get; set; } + public BossData thermonuclear_smoke_devil { get; set; } + public BossData tombs_of_amascut { get; set; } + public BossData tombs_of_amascut_expert { get; set; } + public BossData tzkal_zuk { get; set; } + public BossData tztok_jad { get; set; } + public BossData vardorvis { get; set; } + public BossData venenatis { get; set; } + public BossData vetion { get; set; } + public BossData vorkath { get; set; } + public BossData wintertodt { get; set; } + public BossData yama { get; set; } + public BossData zalcano { get; set; } + public BossData zulrah { get; set; } + } +} diff --git a/osrs-toolbox/APIs/WiseOldMan/Player/PlayerComputed.cs b/osrs-toolbox/APIs/WiseOldMan/Player/PlayerComputed.cs new file mode 100644 index 0000000..94e072c --- /dev/null +++ b/osrs-toolbox/APIs/WiseOldMan/Player/PlayerComputed.cs @@ -0,0 +1,8 @@ +namespace osrs_toolbox +{ + public class PlayerComputed + { + public ComputedData ehp { get; set; } + public ComputedData ehb { get; set; } + } +} diff --git a/osrs-toolbox/APIs/WiseOldMan/Player/PlayerSkills.cs b/osrs-toolbox/APIs/WiseOldMan/Player/PlayerSkills.cs new file mode 100644 index 0000000..89d98ba --- /dev/null +++ b/osrs-toolbox/APIs/WiseOldMan/Player/PlayerSkills.cs @@ -0,0 +1,30 @@ +namespace osrs_toolbox +{ + public class PlayerSkills + { + public SkillData overall { get; set; } + public SkillData attack { get; set; } + public SkillData defence { get; set; } + public SkillData strength { get; set; } + public SkillData hitpoints { get; set; } + public SkillData ranged { get; set; } + public SkillData prayer { get; set; } + public SkillData magic { get; set; } + public SkillData cooking { get; set; } + public SkillData woodcutting { get; set; } + public SkillData fletching { get; set; } + public SkillData fishing { get; set; } + public SkillData firemaking { get; set; } + public SkillData crafting { get; set; } + public SkillData smithing { get; set; } + public SkillData mining { get; set; } + public SkillData herblore { get; set; } + public SkillData agility { get; set; } + public SkillData thieving { get; set; } + public SkillData slayer { get; set; } + public SkillData farming { get; set; } + public SkillData runecrafting { get; set; } + public SkillData hunter { get; set; } + public SkillData construction { get; set; } + } +} diff --git a/osrs-toolbox/APIs/WiseOldMan/Player/SkillData.cs b/osrs-toolbox/APIs/WiseOldMan/Player/SkillData.cs new file mode 100644 index 0000000..7bf6887 --- /dev/null +++ b/osrs-toolbox/APIs/WiseOldMan/Player/SkillData.cs @@ -0,0 +1,11 @@ +namespace osrs_toolbox +{ + public class SkillData + { + public string metric { get; set; } + public int experience { get; set; } + public int rank { get; set; } + public int level { get; set; } + public double ehp { get; set; } + } +} diff --git a/osrs-toolbox/APIs/WiseOldMan/Player/Snapshot.cs b/osrs-toolbox/APIs/WiseOldMan/Player/Snapshot.cs new file mode 100644 index 0000000..3290ea2 --- /dev/null +++ b/osrs-toolbox/APIs/WiseOldMan/Player/Snapshot.cs @@ -0,0 +1,11 @@ +namespace osrs_toolbox +{ + public class Snapshot + { + public int id { get; set; } + public int playerId { get; set; } + public string createdAt { get; set; } + public string importedAt { get; set; } + public SnapshotData data { get; set; } + } +} diff --git a/osrs-toolbox/APIs/WiseOldMan/Player/SnapshotData.cs b/osrs-toolbox/APIs/WiseOldMan/Player/SnapshotData.cs new file mode 100644 index 0000000..2c9561c --- /dev/null +++ b/osrs-toolbox/APIs/WiseOldMan/Player/SnapshotData.cs @@ -0,0 +1,10 @@ +namespace osrs_toolbox +{ + public class SnapshotData + { + public PlayerSkills skills { get; set; } + public PlayerBosses bosses { get; set; } + public PlayerActivities activities { get; set; } + public PlayerComputed computed { get; set; } + } +}