using isnd.Data.Packages;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;

namespace isnd.Data.Catalog
{
    public class PackageRegistration : Permalink
    {

        public PackageRegistration(string url) : base(url)
        {
            Items = new List<CatalogPage>();
        }

        public PackageRegistration(string bid, string apiBase, Packages.Package pkg) : base(bid + $"/{pkg.Id}/index.json")
        {
            Items = new List<CatalogPage>
            {
                new CatalogPage(bid, pkg.Id, apiBase, pkg.Versions)
            };
        }

        [JsonProperty("count")]
        public int Count { get => Items.Count; }

        [JsonProperty("items")]
        public List<CatalogPage> Items { get; set; }
     
    }
}