using System.Net.Sockets;
using System.ComponentModel.DataAnnotations;
using Newtonsoft.Json;
using isnd.Data.Packages;
using NuGet.Versioning;
using System.Collections.Generic;
using System;
using isnd.Interfaces;

namespace isnd.Data.Catalog
{
    public class CatalogEntry : HappyIdOwner  , IObject// , IPackageDetails
    {
        /// <summary>
        /// Creates a catalog entry
        /// </summary>
        /// <param name="id">package details url</param>
        /// <returns></returns>
        public CatalogEntry(string id): base(id)
        {

        }
         /// <summary>
        /// The ID of the package
        /// </summary>
        /// <value></value>

        [JsonProperty("id")]
        public string Id { get; set; }

        /// <summary>
        /// The Package details url
        /// </summary>
        /// <returns></returns>

        [JsonProperty("@id")]
        public string refid { get => GetId(); }


        [JsonProperty("@type")]
        public string[] RefType { get; protected set; } = new string[] { "PackageDetail" };

        [JsonProperty("commitId")]
        public string CommitId { get; set; }

        [JsonProperty("commitTimeStamp")]
        public DateTime CommitTimeStamp { get; set; }

        /// <summary>
        /// Authors
        /// </summary>
        /// <value>string or array of strings</value>
        public string authors { get; set; }

        /// <summary>
        /// The dependencies of the package, grouped by target framework
        /// </summary>
        /// <value>array of objects</value>
        public DependencyGroup[] dependencyGroups { get; set; }

        /// <summary>
        /// The deprecation associated with the package
        /// </summary>
        /// <value></value>
        public Deprecation deprecation { get; set; }

        [JsonProperty("description")]
        public string Description { get; set; }
        public string iconUrl { get; set; }
        public string language { get; set; }

       
        public string licenseUrl { get; set; }
        public string licenseExpression { get; set; }
        /// <summary>
        /// Should be considered as listed if absent
        /// </summary>
        /// <value></value>
        public bool listed { get; set; }
        public string minClientVersion { get; set; }
        public string projectUrl { get; set; }

        public bool requireLicenseAcceptance { get; set; }
        public string summary { get; set; }

        /// <summary>
        /// The tags
        /// </summary>
        /// <value></value>
        public string tags { get; set; }
        public string title { get; set; }

        
        /// <summary>
        /// The security vulnerabilities of the package
        /// </summary>
        /// <value></value>
        public Vulnerabilitie[] vulnerabilities { get; set; }

        public string packageContent { get; set; }

   
        /// <summary>
        /// A string containing a ISO 8601 timestamp of when the package was published
        /// </summary>
        /// <value></value>
        [JsonProperty("published")]
        public DateTime Published { get; set; }

        /// <summary>
        /// The full version string after normalization
        /// </summary>
        /// <value></value>
        [Required,JsonRequired]
        [JsonProperty("version")]
        public string Version { get; set; }

    }
}