using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using StardewModdingAPI.Web.Framework;
using StardewModdingAPI.Web.Models;
namespace StardewModdingAPI.Web.Controllers
{
/// Provides an API to perform mod update checks.
[Produces("application/json")]
[Route("api/check")]
public class CheckController : Controller
{
/*********
** Public methods
*********/
/// Fetch version metadata for the given mods.
/// The mods for which to fetch update metadata.
[HttpPost]
public async Task Post([FromBody] ModSearchModel[] mods)
{
using (NexusModsClient client = new NexusModsClient())
{
List result = new List();
foreach (ModSearchModel mod in mods)
{
if (mod.NexusID.HasValue)
result.Add(await client.GetModInfoAsync(mod.NexusID.Value));
else
result.Add(new ModGenericModel(null, mod.NexusID ?? 0));
}
return result.ToArray();
}
}
}
}