From 2c02dfe45a6d1252bfef557db8f39f97e57d3d19 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Fri, 22 Sep 2017 00:47:46 -0400 Subject: rewrite to make update-check logic vendor-agnostic (#336) --- .../Models/ModGenericModel.cs | 37 ++++++++++------------ src/StardewModdingAPI.Web/Models/ModSearchModel.cs | 6 ++-- 2 files changed, 20 insertions(+), 23 deletions(-) (limited to 'src/StardewModdingAPI.Web/Models') diff --git a/src/StardewModdingAPI.Web/Models/ModGenericModel.cs b/src/StardewModdingAPI.Web/Models/ModGenericModel.cs index dc36c7f4..88a6e4bd 100644 --- a/src/StardewModdingAPI.Web/Models/ModGenericModel.cs +++ b/src/StardewModdingAPI.Web/Models/ModGenericModel.cs @@ -1,3 +1,5 @@ +using Newtonsoft.Json; + namespace StardewModdingAPI.Web.Models { /// Generic metadata about a mod. @@ -6,53 +8,48 @@ namespace StardewModdingAPI.Web.Models /********* ** Accessors *********/ - /// The unique mod ID. - public int ID { get; } + /// The namespaced mod key. + public string ModKey { get; } /// The mod name. public string Name { get; } - /// The mod's vendor ID. - public string Vendor { get; } - /// The mod's semantic version number. public string Version { get; } /// The mod's web URL. public string Url { get; } - /// Whether the mod is valid. - public bool Valid { get; } + /// The error message indicating why the mod is invalid (if applicable). + public string Error { get; } /********* ** Public methods *********/ /// Construct a valid instance. - /// The mod's vendor ID. - /// The unique mod ID. + /// The namespaced mod key. /// The mod name. /// The mod's semantic version number. /// The mod's web URL. - /// Whether the mod is valid. - public ModGenericModel(string vendor, int id, string name, string version, string url, bool valid = true) + /// The error message indicating why the mod is invalid (if applicable). + [JsonConstructor] + public ModGenericModel(string modKey, string name, string version, string url, string error = null) { - this.Vendor = vendor; - this.ID = id; + this.ModKey = modKey; this.Name = name; this.Version = version; this.Url = url; - this.Valid = valid; + this.Error = error; // mainly initialised here for the JSON deserialiser } /// Construct an valid instance. - /// The mod's vendor ID. - /// The unique mod ID. - public ModGenericModel(string vendor, int id) + /// The namespaced mod key. + /// The error message indicating why the mod is invalid. + public ModGenericModel(string modKey, string error) { - this.Vendor = vendor; - this.ID = id; - this.Valid = false; + this.ModKey = modKey; + this.Error = error; } } } diff --git a/src/StardewModdingAPI.Web/Models/ModSearchModel.cs b/src/StardewModdingAPI.Web/Models/ModSearchModel.cs index eb9ac920..852ea439 100644 --- a/src/StardewModdingAPI.Web/Models/ModSearchModel.cs +++ b/src/StardewModdingAPI.Web/Models/ModSearchModel.cs @@ -1,9 +1,9 @@ namespace StardewModdingAPI.Web.Models { - /// The search criteria for a mod. + /// The mod update search criteria. public class ModSearchModel { - /// The Nexus Mods ID (if any). - public int? NexusID { get; set; } + /// The namespaced mod keys to search. + public string[] ModKeys { get; set; } } } -- cgit