using System; using System.Collections.Generic; using System.Linq; using StardewModdingAPI.Toolkit.Framework.UpdateData; namespace StardewModdingAPI.Web.Framework.Clients { /// Generic metadata about a mod page. internal class GenericModPage : IModPage { /********* ** Accessors *********/ /// The mod site containing the mod. public ModSiteKey Site { get; set; } /// The mod's unique ID within the site. public string Id { get; set; } /// The mod name. public string Name { get; set; } /// The mod's semantic version number. public string Version { get; set; } /// The mod's web URL. public string Url { get; set; } /// The mod downloads. public IModDownload[] Downloads { get; set; } = Array.Empty(); /// The mod availability status on the remote site. public RemoteModStatus Status { get; set; } = RemoteModStatus.Ok; /// A user-friendly error which indicates why fetching the mod info failed (if applicable). public string Error { get; set; } /********* ** Public methods *********/ /// Construct an empty instance. public GenericModPage() { } /// Construct an instance. /// The mod site containing the mod. /// The mod's unique ID within the site. public GenericModPage(ModSiteKey site, string id) { this.Site = site; this.Id = id; } /// Set the fetched mod info. /// The mod name. /// The mod's semantic version number. /// The mod's web URL. /// The mod downloads. public IModPage SetInfo(string name, string version, string url, IEnumerable downloads) { this.Name = name; this.Version = version; this.Url = url; this.Downloads = downloads.ToArray(); return this; } /// Set a mod fetch error. /// The mod availability status on the remote site. /// A user-friendly error which indicates why fetching the mod info failed (if applicable). public IModPage SetError(RemoteModStatus status, string error) { this.Status = status; this.Error = error; return this; } } }