using Microsoft.AspNetCore.Mvc;
using isnd.Entities;
using isnd.Services;
using isn.Abstract;
using isn.abst;
using isnd.Interfaces;
using Unleash;
using System.Linq;


namespace isnd.Controllers
{
    /// <summary>
    /// Api Controller
    /// </summary>
    public  class ApiController : Controller
    {
        private readonly IPackageManager packageManager;
        private readonly Resource[] resources;

        /// <summary>
        /// Api Controller Constructor
        /// </summary>
        /// <param name="pm"></param>
        /// <param name="unleashĈlient"></param>
        public ApiController(IPackageManager pm, IUnleash unleashĈlient)
        {
            packageManager = pm;
            resources = packageManager.GetResources(unleashĈlient).ToArray();
        }

        /// <summary>
        /// API index
        /// </summary>
        /// <returns></returns>
        [HttpGet("~" + Constants.ApiVersion + "/index")]
        public IActionResult ApiIndex()
        {
            return Ok(new ApiIndexViewModel(packageManager.CatalogBaseUrl){ Version = PackageManager.BASE_API_LEVEL, Resources = resources });
        }
    }
        
}