/*
 * 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 an image
    /// </summary>
    [DataContract(Name = "ImagePayload")]
    [JsonConverter(typeof(JsonSubtypes), "Type")]
    [JsonSubtypes.KnownSubType(typeof(ContactPayload), "ContactPayload")]
    [JsonSubtypes.KnownSubType(typeof(ImagePayload), "ImagePayload")]
    [JsonSubtypes.KnownSubType(typeof(UrlPayload), "UrlPayload")]
    public partial class ImagePayload : BasePayload, IEquatable<ImagePayload>, IValidatableObject
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="ImagePayload" /> class.
        /// </summary>
        [JsonConstructorAttribute]
        protected ImagePayload() { }
        /// <summary>
        /// Initializes a new instance of the <see cref="ImagePayload" /> class.
        /// </summary>
        /// <param name="payload">The image binary (required).</param>
        /// <param name="contentType">A string representing the media type of the resource (A check is performed to validate the correctness of the provided  content type against the actual image. If the check failed, a bad  request error will be returned.)    The value can be:  - image/jpeg  - image/png  - image/gif  - image/svg.</param>
        /// <param name="isUseExternalBrowser">A flag indicating whether to display the image in an external browser.</param>
        /// <param name="type">Defines the type of the payload (required) (default to &quot;ImagePayload&quot;).</param>
        public ImagePayload(byte[] payload = default(byte[]), string contentType = default(string), bool isUseExternalBrowser = default(bool), string type = "ImagePayload") : base()
        {
            // to ensure "payload" is required (not null)
            if (payload == null)
            {
                throw new ArgumentNullException("payload is a required property for ImagePayload and cannot be null");
            }
            this.Payload = payload;
            // to ensure "type" is required (not null)
            if (type == null)
            {
                throw new ArgumentNullException("type is a required property for ImagePayload and cannot be null");
            }
            this.Type = type;
            this.ContentType = contentType;
            this.IsUseExternalBrowser = isUseExternalBrowser;
        }

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

        /// <summary>
        /// A string representing the media type of the resource (A check is performed to validate the correctness of the provided  content type against the actual image. If the check failed, a bad  request error will be returned.)    The value can be:  - image/jpeg  - image/png  - image/gif  - image/svg
        /// </summary>
        /// <value>A string representing the media type of the resource (A check is performed to validate the correctness of the provided  content type against the actual image. If the check failed, a bad  request error will be returned.)    The value can be:  - image/jpeg  - image/png  - image/gif  - image/svg</value>
        [DataMember(Name = "contentType", EmitDefaultValue = true)]
        public string ContentType { get; set; }

        /// <summary>
        /// A flag indicating whether to display the image in an external browser
        /// </summary>
        /// <value>A flag indicating whether to display the image in an external browser</value>
        [DataMember(Name = "isUseExternalBrowser", EmitDefaultValue = true)]
        public bool IsUseExternalBrowser { 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 ImagePayload {\n");
            sb.Append("  ").Append(base.ToString().Replace("\n", "\n  ")).Append("\n");
            sb.Append("  Payload: ").Append(Payload).Append("\n");
            sb.Append("  ContentType: ").Append(ContentType).Append("\n");
            sb.Append("  IsUseExternalBrowser: ").Append(IsUseExternalBrowser).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 ImagePayload);
        }

        /// <summary>
        /// Returns true if ImagePayload instances are equal
        /// </summary>
        /// <param name="input">Instance of ImagePayload to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(ImagePayload input)
        {
            if (input == null)
            {
                return false;
            }
            return base.Equals(input) && 
                (
                    this.Payload == input.Payload ||
                    (this.Payload != null &&
                    this.Payload.Equals(input.Payload))
                ) && base.Equals(input) && 
                (
                    this.ContentType == input.ContentType ||
                    (this.ContentType != null &&
                    this.ContentType.Equals(input.ContentType))
                ) && base.Equals(input) && 
                (
                    this.IsUseExternalBrowser == input.IsUseExternalBrowser ||
                    this.IsUseExternalBrowser.Equals(input.IsUseExternalBrowser)
                ) && 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.Payload != null)
                {
                    hashCode = (hashCode * 59) + this.Payload.GetHashCode();
                }
                if (this.ContentType != null)
                {
                    hashCode = (hashCode * 59) + this.ContentType.GetHashCode();
                }
                hashCode = (hashCode * 59) + this.IsUseExternalBrowser.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;
        }
    }

}
