/*
 * Tribufu API
 *
 * API to access Tribufu services.
 *
 * The version of the OpenAPI document: 1.2.6
 * Contact: contact@tribufu.com
 * Generated by: https://github.com/openapitools/openapi-generator.git
 */


using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.IO;
using System.Runtime.Serialization;
using System.Text;
using System.Text.RegularExpressions;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
using System.ComponentModel.DataAnnotations;
using OpenAPIDateConverter = Tribufu.Client.OpenAPIDateConverter;

namespace Tribufu.Model
{
    /// <summary>
    /// Package
    /// </summary>
    [DataContract(Name = "Package")]
    public partial class Package : IValidatableObject
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="Package" /> class.
        /// </summary>
        [JsonConstructorAttribute]
        protected Package() { }
        /// <summary>
        /// Initializes a new instance of the <see cref="Package" /> class.
        /// </summary>
        /// <param name="id">id.</param>
        /// <param name="name">name (required).</param>
        /// <param name="description">description.</param>
        /// <param name="authorId">authorId.</param>
        /// <param name="imageUrl">imageUrl (required).</param>
        /// <param name="applicationId">applicationId.</param>
        /// <param name="categoryId">categoryId.</param>
        /// <param name="downloadCount">downloadCount.</param>
        /// <param name="lastDownload">lastDownload.</param>
        /// <param name="releases">releases.</param>
        /// <param name="created">created.</param>
        /// <param name="updated">updated.</param>
        public Package(string id = default(string), string name = default(string), string description = default(string), string authorId = default(string), string imageUrl = default(string), string applicationId = default(string), string categoryId = default(string), int downloadCount = default(int), DateTime? lastDownload = default(DateTime?), List<PackageRelease> releases = default(List<PackageRelease>), DateTime created = default(DateTime), DateTime? updated = default(DateTime?))
        {
            // to ensure "name" is required (not null)
            if (name == null)
            {
                throw new ArgumentNullException("name is a required property for Package and cannot be null");
            }
            this.Name = name;
            // to ensure "imageUrl" is required (not null)
            if (imageUrl == null)
            {
                throw new ArgumentNullException("imageUrl is a required property for Package and cannot be null");
            }
            this.ImageUrl = imageUrl;
            this.Id = id;
            this.Description = description;
            this.AuthorId = authorId;
            this.ApplicationId = applicationId;
            this.CategoryId = categoryId;
            this.DownloadCount = downloadCount;
            this.LastDownload = lastDownload;
            this.Releases = releases;
            this.Created = created;
            this.Updated = updated;
        }

        /// <summary>
        /// Gets or Sets Id
        /// </summary>
        [DataMember(Name = "id", EmitDefaultValue = false)]
        public string Id { get; set; }

        /// <summary>
        /// Gets or Sets Name
        /// </summary>
        [DataMember(Name = "name", IsRequired = true, EmitDefaultValue = true)]
        public string Name { get; set; }

        /// <summary>
        /// Gets or Sets Description
        /// </summary>
        [DataMember(Name = "description", EmitDefaultValue = true)]
        public string Description { get; set; }

        /// <summary>
        /// Gets or Sets AuthorId
        /// </summary>
        [DataMember(Name = "author_id", EmitDefaultValue = false)]
        public string AuthorId { get; set; }

        /// <summary>
        /// Gets or Sets ImageUrl
        /// </summary>
        [DataMember(Name = "image_url", IsRequired = true, EmitDefaultValue = true)]
        public string ImageUrl { get; set; }

        /// <summary>
        /// Gets or Sets ApplicationId
        /// </summary>
        [DataMember(Name = "application_id", EmitDefaultValue = true)]
        public string ApplicationId { get; set; }

        /// <summary>
        /// Gets or Sets CategoryId
        /// </summary>
        [DataMember(Name = "category_id", EmitDefaultValue = true)]
        public string CategoryId { get; set; }

        /// <summary>
        /// Gets or Sets DownloadCount
        /// </summary>
        [DataMember(Name = "download_count", EmitDefaultValue = false)]
        public int DownloadCount { get; set; }

        /// <summary>
        /// Gets or Sets LastDownload
        /// </summary>
        [DataMember(Name = "last_download", EmitDefaultValue = true)]
        public DateTime? LastDownload { get; set; }

        /// <summary>
        /// Gets or Sets Releases
        /// </summary>
        [DataMember(Name = "releases", EmitDefaultValue = true)]
        public List<PackageRelease> Releases { get; set; }

        /// <summary>
        /// Gets or Sets Created
        /// </summary>
        [DataMember(Name = "created", EmitDefaultValue = false)]
        public DateTime Created { get; set; }

        /// <summary>
        /// Gets or Sets Updated
        /// </summary>
        [DataMember(Name = "updated", EmitDefaultValue = true)]
        public DateTime? Updated { get; set; }

        /// <summary>
        /// Returns the string presentation of the object
        /// </summary>
        /// <returns>String presentation of the object</returns>
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("class Package {\n");
            sb.Append("  Id: ").Append(Id).Append("\n");
            sb.Append("  Name: ").Append(Name).Append("\n");
            sb.Append("  Description: ").Append(Description).Append("\n");
            sb.Append("  AuthorId: ").Append(AuthorId).Append("\n");
            sb.Append("  ImageUrl: ").Append(ImageUrl).Append("\n");
            sb.Append("  ApplicationId: ").Append(ApplicationId).Append("\n");
            sb.Append("  CategoryId: ").Append(CategoryId).Append("\n");
            sb.Append("  DownloadCount: ").Append(DownloadCount).Append("\n");
            sb.Append("  LastDownload: ").Append(LastDownload).Append("\n");
            sb.Append("  Releases: ").Append(Releases).Append("\n");
            sb.Append("  Created: ").Append(Created).Append("\n");
            sb.Append("  Updated: ").Append(Updated).Append("\n");
            sb.Append("}\n");
            return sb.ToString();
        }

        /// <summary>
        /// Returns the JSON string presentation of the object
        /// </summary>
        /// <returns>JSON string presentation of the object</returns>
        public virtual string ToJson()
        {
            return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented);
        }

        /// <summary>
        /// To validate all properties of the instance
        /// </summary>
        /// <param name="validationContext">Validation context</param>
        /// <returns>Validation Result</returns>
        IEnumerable<ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
        {
            // Name (string) maxLength
            if (this.Name != null && this.Name.Length > 45)
            {
                yield return new ValidationResult("Invalid value for Name, length must be less than 45.", new [] { "Name" });
            }

            yield break;
        }
    }

}
