diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-09-22 00:13:04 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-09-22 00:13:04 -0400 |
commit | edbc3ef3c08909486d6c4b8797f0e3c2934854fa (patch) | |
tree | e59aea823b05def6f6da36fae702f6121b0527e4 /src/StardewModdingAPI.Web/Models | |
parent | dfae52b1e57677c1efa052b1073a2e8a56f32163 (diff) | |
download | SMAPI-edbc3ef3c08909486d6c4b8797f0e3c2934854fa.tar.gz SMAPI-edbc3ef3c08909486d6c4b8797f0e3c2934854fa.tar.bz2 SMAPI-edbc3ef3c08909486d6c4b8797f0e3c2934854fa.zip |
refactor Nexus code into generic vendor, rewrite using fluent HTTP client (#336)
Diffstat (limited to 'src/StardewModdingAPI.Web/Models')
-rw-r--r-- | src/StardewModdingAPI.Web/Models/IModModel.cs | 12 | ||||
-rw-r--r-- | src/StardewModdingAPI.Web/Models/ModGenericModel.cs | 43 | ||||
-rw-r--r-- | src/StardewModdingAPI.Web/Models/NexusResponseModel.cs | 41 |
3 files changed, 37 insertions, 59 deletions
diff --git a/src/StardewModdingAPI.Web/Models/IModModel.cs b/src/StardewModdingAPI.Web/Models/IModModel.cs deleted file mode 100644 index 2eadcaec..00000000 --- a/src/StardewModdingAPI.Web/Models/IModModel.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace StardewModdingAPI.Web.Models -{ - /// <summary>A mod metadata response which provides a method to extract generic info.</summary> - internal interface IModModel - { - /********* - ** Public methods - *********/ - /// <summary>Get basic mod metadata.</summary> - ModGenericModel ModInfo(); - } -} diff --git a/src/StardewModdingAPI.Web/Models/ModGenericModel.cs b/src/StardewModdingAPI.Web/Models/ModGenericModel.cs index 208af416..dc36c7f4 100644 --- a/src/StardewModdingAPI.Web/Models/ModGenericModel.cs +++ b/src/StardewModdingAPI.Web/Models/ModGenericModel.cs @@ -7,21 +7,52 @@ namespace StardewModdingAPI.Web.Models ** Accessors *********/ /// <summary>The unique mod ID.</summary> - public int ID { get; set; } + public int ID { get; } /// <summary>The mod name.</summary> - public string Name { get; set; } + public string Name { get; } /// <summary>The mod's vendor ID.</summary> - public string Vendor { get; set; } + public string Vendor { get; } /// <summary>The mod's semantic version number.</summary> - public string Version { get; set; } + public string Version { get; } /// <summary>The mod's web URL.</summary> - public string Url { get; set; } + public string Url { get; } /// <summary>Whether the mod is valid.</summary> - public bool Valid { get; set; } = true; + public bool Valid { 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="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) + { + this.Vendor = vendor; + this.ID = id; + this.Name = name; + this.Version = version; + this.Url = url; + this.Valid = valid; + } + + /// <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) + { + this.Vendor = vendor; + this.ID = id; + this.Valid = false; + } } } diff --git a/src/StardewModdingAPI.Web/Models/NexusResponseModel.cs b/src/StardewModdingAPI.Web/Models/NexusResponseModel.cs deleted file mode 100644 index ae5c691c..00000000 --- a/src/StardewModdingAPI.Web/Models/NexusResponseModel.cs +++ /dev/null @@ -1,41 +0,0 @@ -using Newtonsoft.Json; - -namespace StardewModdingAPI.Web.Models -{ - /// <summary>A mod metadata response from Nexus Mods.</summary> - public class NexusResponseModel : IModModel - { - /********* - ** Accessors - *********/ - /// <summary>The unique mod ID.</summary> - public int ID { get; set; } - - /// <summary>The mod name.</summary> - public string Name { get; set; } - - /// <summary>The mod's semantic version number.</summary> - public string Version { get; set; } - - /// <summary>The mod's web URL.</summary> - [JsonProperty("mod_page_uri")] - public string Url { get; set; } - - - /********* - ** Public methods - *********/ - /// <summary>Get basic mod metadata.</summary> - public ModGenericModel ModInfo() - { - return new ModGenericModel - { - ID = this.ID, - Version = this.Version, - Name = this.Name, - Url = this.Url, - Vendor = "Nexus" - }; - } - } -} |