using System.Collections.Generic; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System; public class SchakenMods { [JsonProperty("download")] public Download Mod { get; set; } [JsonProperty("SMAccountInfo")] public SMAccountInfo SettingsJSON { get; set; } [JsonProperty("author")] public User Author { get; set; } public class FieldsJsonConverter : JsonConverter { public override bool CanConvert(Type objectType) { return objectType == typeof(Dictionary); } public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { JToken token = JToken.Load(reader); if (token.Type == JTokenType.Array && !token.HasValues) { return new Dictionary(); } return token.ToObject>(serializer); } public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { var dictionary = (Dictionary)value; writer.WriteStartObject(); foreach (var kvp in dictionary) { writer.WritePropertyName(kvp.Key); serializer.Serialize(writer, kvp.Value); } writer.WriteEndObject(); } } public class VersionInfo { [JsonProperty("id")] public int Id { get; set; } [JsonProperty("version")] public string Version { get; set; } [JsonProperty("changelog")] public string Changelog { get; set; } [JsonProperty("hidden")] public bool Hidden { get; set; } [JsonProperty("date")] public string Date { get; set; } } public class VersionFilesResponse { [JsonProperty("files")] public List Files { get; set; } } public class VersionFiles { [JsonProperty("name")] public string Name { get; set; } [JsonProperty("url")] public string URL { get; set; } [JsonProperty("size")] public long Size { get; set; } } public class SMAccountInfo { [JsonProperty("access_token")] public string Access_Token { get; set; } [JsonProperty("refresh_token")] public string Refresh_Token { get; set; } [JsonProperty("StayLoggedIn")] public bool Stay_Logged_In { get; set; } [JsonProperty("scope")] public string Scope { get; set; } [JsonProperty("expires_in")] public long Expires_In { get; set; } [JsonProperty("expire")] public DateTime? Expire { get; set; } } public class Download { [JsonProperty("id")] public int Id { get; set; } [JsonProperty("title")] public string Title { get; set; } [JsonProperty("category")] public Category ModCategory { get; set; } [JsonProperty("date")] public DateTime Date { get; set; } [JsonProperty("updated")] public DateTime Updated { get; set; } [JsonProperty("author")] public User ModAuthor { get; set; } [JsonProperty("description")] public string Description { get; set; } [JsonProperty("version")] public string Version { get; set; } [JsonProperty("changelog")] public string Changelog { get; set; } [JsonProperty("screenshots")] public List Screenshots { get; set; } [JsonProperty("screenshotsThumbnails")] public List ScreenshotThumbnails { get; set; } [JsonProperty("primaryScreenshot")] public Screenshot PrimaryScreenshot { get; set; } [JsonProperty("primaryScreenshotThumb")] public ScreenshotThumbnail PrimaryScreenshotThumb { get; set; } [JsonProperty("downloads")] public int Downloads { get; set; } [JsonProperty("comments")] public int Comments { get; set; } [JsonProperty("reviews")] public int Reviews { get; set; } [JsonProperty("views")] public int Views { get; set; } [JsonProperty("prefix")] public string Prefix { get; set; } [JsonProperty("tags")] public List Tags { get; set; } [JsonProperty("locked")] public bool Locked { get; set; } [JsonProperty("hidden")] public bool Hidden { get; set; } [JsonProperty("pinned")] public bool Pinned { get; set; } [JsonProperty("featured")] public bool Featured { get; set; } [JsonProperty("url")] public string Url { get; set; } [JsonProperty("isPaid")] public bool IsPaid { get; set; } [JsonProperty("isPurchasable")] public bool IsPurchasable { get; set; } [JsonProperty("prices")] public object Prices { get; set; } [JsonProperty("canDownload")] public bool? CanDownload { get; set; } [JsonProperty("canBuy")] public bool? CanBuy { get; set; } [JsonProperty("canReview")] public bool? CanReview { get; set; } [JsonProperty("rating")] public float Rating { get; set; } [JsonProperty("purchases")] public int Purchases { get; set; } [JsonProperty("renewalTerm")] public object RenewalTerm { get; set; } [JsonProperty("hasPendingVersion")] public bool? HasPendingVersion { get; set; } [JsonProperty("downloaded")] public DateTime Downloaded { get; set; } } public class Topic { [JsonProperty("id")] public int? Id { get; set; } [JsonProperty("title")] public string Title { get; set; } [JsonProperty("forum")] public Forum Forum { get; set; } [JsonProperty("posts")] public int? Posts { get; set; } [JsonProperty("views")] public int? Views { get; set; } [JsonProperty("prefix")] public string Prefix { get; set; } [JsonProperty("tags")] public List Tags { get; set; } [JsonProperty("firstPost")] public Post FirstPost { get; set; } [JsonProperty("lastPost")] public Post LastPost { get; set; } [JsonProperty("bestAnswer")] public Post BestAnswer { get; set; } [JsonProperty("locked")] public bool? Locked { get; set; } [JsonProperty("hidden")] public bool? Hidden { get; set; } [JsonProperty("pinned")] public bool? Pinned { get; set; } [JsonProperty("featured")] public bool? Featured { get; set; } [JsonProperty("archived")] public bool? Archived { get; set; } [JsonProperty("poll")] public object Poll { get; set; } // Assuming you don't have a specific class for this [JsonProperty("url")] public string Url { get; set; } [JsonProperty("rating")] public int? Rating { get; set; } [JsonProperty("is_future_entry")] public int? IsFutureEntry { get; set; } [JsonProperty("publish_date")] public DateTime? PublishDate { get; set; } } public class Forum { [JsonProperty("id")] public int? Id { get; set; } [JsonProperty("name")] public string Name { get; set; } [JsonProperty("path")] public string Path { get; set; } [JsonProperty("type")] public string Type { get; set; } [JsonProperty("topics")] public int? Topics { get; set; } [JsonProperty("url")] public string Url { get; set; } [JsonProperty("parentId")] public int? ParentId { get; set; } [JsonProperty("club")] public int? Club { get; set; } } public class Post { [JsonProperty("id")] public int? Id { get; set; } [JsonProperty("item_id")] public int? ItemId { get; set; } [JsonProperty("author")] public User Author { get; set; } [JsonProperty("date")] public DateTime? Date { get; set; } [JsonProperty("content")] public string Content { get; set; } [JsonProperty("hidden")] public bool? Hidden { get; set; } [JsonProperty("url")] public string Url { get; set; } [JsonProperty("reactions")] public List Reactions { get; set; } // Assuming you don't have a specific class for this } public class Group { [JsonProperty("id")] public int? Id { get; set; } [JsonProperty("name")] public string Name { get; set; } [JsonProperty("formattedName")] public string FormattedName { get; set; } } public class Category { [JsonProperty("id")] public int Id { get; set; } [JsonProperty("name")] public string Name { get; set; } [JsonProperty("url")] public string Url { get; set; } [JsonProperty("class")] public string Class { get; set; } [JsonProperty("parentId")] public int ParentId { get; set; } [JsonProperty("club")] public object Club { get { return _club; } set { if (value is JObject) { _club = JsonConvert.DeserializeObject(((JObject)value).ToString()); } else if (value is long) { // Handle the case where club is an integer // For example, you might want to set _club to null or throw an exception _club = null; } } } private Club _club; } public class User { [JsonProperty("id")] public int Id { get; set; } [JsonProperty("name")] public string Name { get; set; } [JsonProperty("title")] public string Title { get; set; } [JsonProperty("formattedName")] public string FormattedName { get; set; } [JsonProperty("primaryGroup")] public PrimaryGroup PrimaryGroup { get; set; } [JsonProperty("joined")] public DateTime Joined { get; set; } [JsonProperty("reputationPoints")] public int ReputationPoints { get; set; } [JsonProperty("photoUrl")] public string PhotoUrl { get; set; } [JsonProperty("photoUrlIsDefault")] public bool PhotoUrlIsDefault { get; set; } [JsonProperty("coverPhotoUrl")] public string CoverPhotoUrl { get; set; } [JsonProperty("profileUrl")] public string ProfileUrl { get; set; } [JsonProperty("posts")] public int Posts { get; set; } [JsonProperty("lastActivity")] public DateTime? LastActivity { get; set; } [JsonProperty("birthday")] public DateTime? Birthday { get; set; } [JsonProperty("profileViews")] public int ProfileViews { get; set; } [JsonProperty("customFields")] public Dictionary CustomFields { get; set; } [JsonProperty("rank")] public Rank Rank { get; set; } [JsonProperty("achievements_points")] public int AchievementsPoints { get; set; } [JsonProperty("allowAdminEmails")] public bool AllowAdminEmails { get; set; } [JsonProperty("completed")] public bool Completed { get; set; } [JsonProperty("lastVisit")] public DateTime? LastVisit { get; set; } [JsonProperty("lastPost")] public DateTime? LastPost { get; set; } } public class PrimaryGroup { [JsonProperty("id")] public int Id { get; set; } [JsonProperty("name")] public string Name { get; set; } [JsonProperty("formattedName")] public string FormattedName { get; set; } } public class CustomField { [JsonProperty("name")] public string Name { get; set; } [JsonProperty("fields")] [JsonConverter(typeof(FieldsJsonConverter))] public Dictionary Fields { get; set; } } public class Field { [JsonProperty("name")] public string Name { get; set; } [JsonProperty("value")] public string Value { get; set; } } public class Rank { [JsonProperty("id")] public int Id { get; set; } [JsonProperty("name")] public string Name { get; set; } [JsonProperty("icon")] public string Icon { get; set; } [JsonProperty("points")] public int Points { get; set; } } public class Screenshot { [JsonProperty("name")] public string Name { get; set; } [JsonProperty("url")] public string Url { get; set; } [JsonProperty("size")] public long Size { get; set; } } public class ScreenshotThumbnail { [JsonProperty("name")] public string Name { get; set; } [JsonProperty("url")] public string Url { get; set; } [JsonProperty("size")] public int Size { get; set; } } public class Club { [JsonProperty("id")] public int Id { get; set; } [JsonProperty("name")] public string Name { get; set; } [JsonProperty("url")] public string Url { get; set; } [JsonProperty("type")] public string Type { get; set; } [JsonProperty("created")] public DateTime Created { get; set; } [JsonProperty("memberCount")] public int MemberCount { get; set; } [JsonProperty("owner")] public User Owner { get; set; } [JsonProperty("photo")] public string Photo { get; set; } [JsonProperty("featured")] public bool Featured { get; set; } [JsonProperty("paid")] public bool Paid { get; set; } [JsonProperty("location")] public string Location { get; set; } [JsonProperty("about")] public string About { get; set; } [JsonProperty("lastActivity")] public DateTime LastActivity { get; set; } [JsonProperty("contentCount")] public int ContentCount { get; set; } [JsonProperty("coverPhotoUrl")] public string CoverPhotoUrl { get; set; } [JsonProperty("coverOffset")] public int? CoverOffset { get; set; } [JsonProperty("coverPhotoColor")] public string CoverPhotoColor { get; set; } [JsonProperty("members")] public List Members { get; set; } [JsonProperty("leaders")] public List Leaders { get; set; } [JsonProperty("moderators")] public List Moderators { get; set; } [JsonProperty("fieldValues")] public List FieldValues { get; set; } [JsonProperty("nodes")] public Dictionary Nodes { get; set; } [JsonProperty("joiningFee")] public object JoiningFee { get; set; } [JsonProperty("renewalTerm")] public object RenewalTerm { get; set; } } public class FieldValue { [JsonProperty("name")] public string Name { get; set; } [JsonProperty("value")] public string Value { get; set; } } public class Node { [JsonProperty("name")] public string Name { get; set; } [JsonProperty("url")] public string Url { get; set; } [JsonProperty("public")] public int Public { get; set; } [JsonProperty("id")] public int Id { get; set; } [JsonProperty("class")] public string Class { get; set; } } }