summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI.Web/Models/ModInfoModel.cs
blob: 723d6c73f649a7fee2bd844a128191ee63279a6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using Newtonsoft.Json;

namespace StardewModdingAPI.Web.Models
{
    /// <summary>Generic metadata about a mod.</summary>
    public class ModInfoModel
    {
        /*********
        ** Accessors
        *********/
        /// <summary>The namespaced mod key.</summary>
        public string ModKey { get; }

        /// <summary>The mod name.</summary>
        public string Name { 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>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="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="error">The error message indicating why the mod is invalid (if applicable).</param>
        [JsonConstructor]
        public ModInfoModel(string modKey, string name, string version, string url, string error = null)
        {
            this.ModKey = modKey;
            this.Name = name;
            this.Version = version;
            this.Url = url;
            this.Error = error; // mainly initialised here for the JSON deserialiser
        }

        /// <summary>Construct an valid instance.</summary>
        /// <param name="modKey">The namespaced mod key.</param>
        /// <param name="error">The error message indicating why the mod is invalid.</param>
        public ModInfoModel(string modKey, string error)
        {
            this.ModKey = modKey;
            this.Error = error;
        }
    }
}