summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI.Web/Models
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2017-09-22 00:47:46 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2017-09-22 00:47:46 -0400
commit2c02dfe45a6d1252bfef557db8f39f97e57d3d19 (patch)
tree4fb8b5759d56ba6a62a452e09180ede280228b3b /src/StardewModdingAPI.Web/Models
parentedbc3ef3c08909486d6c4b8797f0e3c2934854fa (diff)
downloadSMAPI-2c02dfe45a6d1252bfef557db8f39f97e57d3d19.tar.gz
SMAPI-2c02dfe45a6d1252bfef557db8f39f97e57d3d19.tar.bz2
SMAPI-2c02dfe45a6d1252bfef557db8f39f97e57d3d19.zip
rewrite to make update-check logic vendor-agnostic (#336)
Diffstat (limited to 'src/StardewModdingAPI.Web/Models')
-rw-r--r--src/StardewModdingAPI.Web/Models/ModGenericModel.cs37
-rw-r--r--src/StardewModdingAPI.Web/Models/ModSearchModel.cs6
2 files changed, 20 insertions, 23 deletions
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
{
/// <summary>Generic metadata about a mod.</summary>
@@ -6,53 +8,48 @@ namespace StardewModdingAPI.Web.Models
/*********
** Accessors
*********/
- /// <summary>The unique mod ID.</summary>
- public int ID { get; }
+ /// <summary>The namespaced mod key.</summary>
+ public string ModKey { get; }
/// <summary>The mod name.</summary>
public string Name { get; }
- /// <summary>The mod's vendor ID.</summary>
- public string Vendor { get; }
-
/// <summary>The mod's semantic version number.</summary>
public string Version { get; }
/// <summary>The mod's web URL.</summary>
public string Url { get; }
- /// <summary>Whether the mod is valid.</summary>
- public bool Valid { get; }
+ /// <summary>The error message indicating why the mod is invalid (if applicable).</summary>
+ public string Error { get; }
/*********
** Public methods
*********/
/// <summary>Construct a valid instance.</summary>
- /// <param name="vendor">The mod's vendor ID.</param>
- /// <param name="id">The unique mod ID.</param>
+ /// <param name="modKey">The namespaced mod key.</param>
/// <param name="name">The mod name.</param>
/// <param name="version">The mod's semantic version number.</param>
/// <param name="url">The mod's web URL.</param>
- /// <param name="valid">Whether the mod is valid.</param>
- public ModGenericModel(string vendor, int id, string name, string version, string url, bool valid = true)
+ /// <param name="error">The error message indicating why the mod is invalid (if applicable).</param>
+ [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
}
/// <summary>Construct an valid instance.</summary>
- /// <param name="vendor">The mod's vendor ID.</param>
- /// <param name="id">The unique mod ID.</param>
- public ModGenericModel(string vendor, int id)
+ /// <param name="modKey">The namespaced mod key.</param>
+ /// <param name="error">The error message indicating why the mod is invalid.</param>
+ 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
{
- /// <summary>The search criteria for a mod.</summary>
+ /// <summary>The mod update search criteria.</summary>
public class ModSearchModel
{
- /// <summary>The Nexus Mods ID (if any).</summary>
- public int? NexusID { get; set; }
+ /// <summary>The namespaced mod keys to search.</summary>
+ public string[] ModKeys { get; set; }
}
}