/*
 * SMAC API
 *
 * SMAC ASP.NET Core Web API
 *
 * The version of the OpenAPI document: v1
 * 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 JsonSubTypes;
using System.ComponentModel.DataAnnotations;
using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter;

namespace Org.OpenAPITools.Model
{
    /// <summary>
    /// A payload containing a VCard
    /// </summary>
    [DataContract(Name = "ContactPayload")]
    [JsonConverter(typeof(JsonSubtypes), "Type")]
    [JsonSubtypes.KnownSubType(typeof(ContactPayload), "ContactPayload")]
    [JsonSubtypes.KnownSubType(typeof(ImagePayload), "ImagePayload")]
    [JsonSubtypes.KnownSubType(typeof(UrlPayload), "UrlPayload")]
    public partial class ContactPayload : BasePayload, IEquatable<ContactPayload>, IValidatableObject
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="ContactPayload" /> class.
        /// </summary>
        [JsonConstructorAttribute]
        protected ContactPayload() { }
        /// <summary>
        /// Initializes a new instance of the <see cref="ContactPayload" /> class.
        /// </summary>
        /// <param name="firstName">First name or given name.</param>
        /// <param name="lastName">Last name or surname.</param>
        /// <param name="organization">Organization or company name.</param>
        /// <param name="jobTitle">Job title.</param>
        /// <param name="image">The image binary (Base64 format).</param>
        /// <param name="homeContact">homeContact.</param>
        /// <param name="workContact">workContact.</param>
        /// <param name="type">Defines the type of the payload (required) (default to &quot;ContactPayload&quot;).</param>
        public ContactPayload(string firstName = default(string), string lastName = default(string), string organization = default(string), string jobTitle = default(string), byte[] image = default(byte[]), VCardContact homeContact = default(VCardContact), VCardContact workContact = default(VCardContact), string type = "ContactPayload") : base()
        {
            // to ensure "type" is required (not null)
            if (type == null)
            {
                throw new ArgumentNullException("type is a required property for ContactPayload and cannot be null");
            }
            this.Type = type;
            this.FirstName = firstName;
            this.LastName = lastName;
            this.Organization = organization;
            this.JobTitle = jobTitle;
            this.Image = image;
            this.HomeContact = homeContact;
            this.WorkContact = workContact;
        }

        /// <summary>
        /// First name or given name
        /// </summary>
        /// <value>First name or given name</value>
        [DataMember(Name = "firstName", EmitDefaultValue = true)]
        public string FirstName { get; set; }

        /// <summary>
        /// Last name or surname
        /// </summary>
        /// <value>Last name or surname</value>
        [DataMember(Name = "lastName", EmitDefaultValue = true)]
        public string LastName { get; set; }

        /// <summary>
        /// Organization or company name
        /// </summary>
        /// <value>Organization or company name</value>
        [DataMember(Name = "organization", EmitDefaultValue = true)]
        public string Organization { get; set; }

        /// <summary>
        /// Job title
        /// </summary>
        /// <value>Job title</value>
        [DataMember(Name = "jobTitle", EmitDefaultValue = true)]
        public string JobTitle { get; set; }

        /// <summary>
        /// The image binary (Base64 format)
        /// </summary>
        /// <value>The image binary (Base64 format)</value>
        [DataMember(Name = "image", EmitDefaultValue = true)]
        public byte[] Image { get; set; }

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

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

        /// <summary>
        /// Defines the type of the payload
        /// </summary>
        /// <value>Defines the type of the payload</value>
        [DataMember(Name = "type", IsRequired = true, EmitDefaultValue = true)]
        public string Type { 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 ContactPayload {\n");
            sb.Append("  ").Append(base.ToString().Replace("\n", "\n  ")).Append("\n");
            sb.Append("  FirstName: ").Append(FirstName).Append("\n");
            sb.Append("  LastName: ").Append(LastName).Append("\n");
            sb.Append("  Organization: ").Append(Organization).Append("\n");
            sb.Append("  JobTitle: ").Append(JobTitle).Append("\n");
            sb.Append("  Image: ").Append(Image).Append("\n");
            sb.Append("  HomeContact: ").Append(HomeContact).Append("\n");
            sb.Append("  WorkContact: ").Append(WorkContact).Append("\n");
            sb.Append("  Type: ").Append(Type).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 override string ToJson()
        {
            return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented);
        }

        /// <summary>
        /// Returns true if objects are equal
        /// </summary>
        /// <param name="input">Object to be compared</param>
        /// <returns>Boolean</returns>
        public override bool Equals(object input)
        {
            return this.Equals(input as ContactPayload);
        }

        /// <summary>
        /// Returns true if ContactPayload instances are equal
        /// </summary>
        /// <param name="input">Instance of ContactPayload to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(ContactPayload input)
        {
            if (input == null)
            {
                return false;
            }
            return base.Equals(input) && 
                (
                    this.FirstName == input.FirstName ||
                    (this.FirstName != null &&
                    this.FirstName.Equals(input.FirstName))
                ) && base.Equals(input) && 
                (
                    this.LastName == input.LastName ||
                    (this.LastName != null &&
                    this.LastName.Equals(input.LastName))
                ) && base.Equals(input) && 
                (
                    this.Organization == input.Organization ||
                    (this.Organization != null &&
                    this.Organization.Equals(input.Organization))
                ) && base.Equals(input) && 
                (
                    this.JobTitle == input.JobTitle ||
                    (this.JobTitle != null &&
                    this.JobTitle.Equals(input.JobTitle))
                ) && base.Equals(input) && 
                (
                    this.Image == input.Image ||
                    (this.Image != null &&
                    this.Image.Equals(input.Image))
                ) && base.Equals(input) && 
                (
                    this.HomeContact == input.HomeContact ||
                    (this.HomeContact != null &&
                    this.HomeContact.Equals(input.HomeContact))
                ) && base.Equals(input) && 
                (
                    this.WorkContact == input.WorkContact ||
                    (this.WorkContact != null &&
                    this.WorkContact.Equals(input.WorkContact))
                ) && base.Equals(input) && 
                (
                    this.Type == input.Type ||
                    (this.Type != null &&
                    this.Type.Equals(input.Type))
                );
        }

        /// <summary>
        /// Gets the hash code
        /// </summary>
        /// <returns>Hash code</returns>
        public override int GetHashCode()
        {
            unchecked // Overflow is fine, just wrap
            {
                int hashCode = base.GetHashCode();
                if (this.FirstName != null)
                {
                    hashCode = (hashCode * 59) + this.FirstName.GetHashCode();
                }
                if (this.LastName != null)
                {
                    hashCode = (hashCode * 59) + this.LastName.GetHashCode();
                }
                if (this.Organization != null)
                {
                    hashCode = (hashCode * 59) + this.Organization.GetHashCode();
                }
                if (this.JobTitle != null)
                {
                    hashCode = (hashCode * 59) + this.JobTitle.GetHashCode();
                }
                if (this.Image != null)
                {
                    hashCode = (hashCode * 59) + this.Image.GetHashCode();
                }
                if (this.HomeContact != null)
                {
                    hashCode = (hashCode * 59) + this.HomeContact.GetHashCode();
                }
                if (this.WorkContact != null)
                {
                    hashCode = (hashCode * 59) + this.WorkContact.GetHashCode();
                }
                if (this.Type != null)
                {
                    hashCode = (hashCode * 59) + this.Type.GetHashCode();
                }
                return hashCode;
            }
        }

        /// <summary>
        /// To validate all properties of the instance
        /// </summary>
        /// <param name="validationContext">Validation context</param>
        /// <returns>Validation Result</returns>
        public IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> Validate(ValidationContext validationContext)
        {
            return this.BaseValidate(validationContext);
        }

        /// <summary>
        /// To validate all properties of the instance
        /// </summary>
        /// <param name="validationContext">Validation context</param>
        /// <returns>Validation Result</returns>
        protected IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> BaseValidate(ValidationContext validationContext)
        {
            foreach (var x in base.BaseValidate(validationContext))
            {
                yield return x;
            }
            // Type (string) minLength
            if (this.Type != null && this.Type.Length < 1)
            {
                yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Type, length must be greater than 1.", new [] { "Type" });
            }

            yield break;
        }
    }

}
