/*
 * 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 System.ComponentModel.DataAnnotations;
using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter;

namespace Org.OpenAPITools.Model
{
    /// <summary>
    /// AuthenticateResponse
    /// </summary>
    [DataContract(Name = "AuthenticateResponse")]
    public partial class AuthenticateResponse : IEquatable<AuthenticateResponse>, IValidatableObject
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="AuthenticateResponse" /> class.
        /// </summary>
        [JsonConstructorAttribute]
        protected AuthenticateResponse() { }
        /// <summary>
        /// Initializes a new instance of the <see cref="AuthenticateResponse" /> class.
        /// </summary>
        /// <param name="userId">The user identifier.</param>
        /// <param name="email">The user email address.</param>
        /// <param name="roles">The user roles.</param>
        /// <param name="token">The access token to be used when calling APIs (required).</param>
        /// <param name="tokenType">The access token type.</param>
        /// <param name="expires">expires.</param>
        /// <param name="validUntil">The expiry date-time in notation as defined by RFC 3339, section 5.6, for example, &lt;em&gt;2017-07-21T17:32:28Z&lt;/em&gt;.</param>
        /// <param name="refreshToken">The refresh token (It is used to retrieve new access token via &lt;a href&#x3D;\&quot;#operations-Users-post_api_Users_refresh_token\&quot;&gt;/api/Users/refresh-token&lt;/a&gt;.).</param>
        public AuthenticateResponse(Guid userId = default(Guid), string email = default(string), List<string> roles = default(List<string>), string token = default(string), string tokenType = default(string), int expires = default(int), DateTime validUntil = default(DateTime), string refreshToken = default(string))
        {
            // to ensure "token" is required (not null)
            if (token == null)
            {
                throw new ArgumentNullException("token is a required property for AuthenticateResponse and cannot be null");
            }
            this.Token = token;
            this.UserId = userId;
            this.Email = email;
            this.Roles = roles;
            this.TokenType = tokenType;
            this.Expires = expires;
            this.ValidUntil = validUntil;
            this.RefreshToken = refreshToken;
        }

        /// <summary>
        /// The user identifier
        /// </summary>
        /// <value>The user identifier</value>
        [DataMember(Name = "userId", EmitDefaultValue = false)]
        public Guid UserId { get; set; }

        /// <summary>
        /// The user email address
        /// </summary>
        /// <value>The user email address</value>
        [DataMember(Name = "email", EmitDefaultValue = true)]
        public string Email { get; set; }

        /// <summary>
        /// The user roles
        /// </summary>
        /// <value>The user roles</value>
        [DataMember(Name = "roles", EmitDefaultValue = true)]
        public List<string> Roles { get; set; }

        /// <summary>
        /// The access token to be used when calling APIs
        /// </summary>
        /// <value>The access token to be used when calling APIs</value>
        [DataMember(Name = "token", IsRequired = true, EmitDefaultValue = true)]
        public string Token { get; set; }

        /// <summary>
        /// The access token type
        /// </summary>
        /// <value>The access token type</value>
        [DataMember(Name = "tokenType", EmitDefaultValue = true)]
        public string TokenType { get; set; }

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

        /// <summary>
        /// The expiry date-time in notation as defined by RFC 3339, section 5.6, for example, &lt;em&gt;2017-07-21T17:32:28Z&lt;/em&gt;
        /// </summary>
        /// <value>The expiry date-time in notation as defined by RFC 3339, section 5.6, for example, &lt;em&gt;2017-07-21T17:32:28Z&lt;/em&gt;</value>
        [DataMember(Name = "validUntil", EmitDefaultValue = false)]
        public DateTime ValidUntil { get; set; }

        /// <summary>
        /// The refresh token (It is used to retrieve new access token via &lt;a href&#x3D;\&quot;#operations-Users-post_api_Users_refresh_token\&quot;&gt;/api/Users/refresh-token&lt;/a&gt;.)
        /// </summary>
        /// <value>The refresh token (It is used to retrieve new access token via &lt;a href&#x3D;\&quot;#operations-Users-post_api_Users_refresh_token\&quot;&gt;/api/Users/refresh-token&lt;/a&gt;.)</value>
        [DataMember(Name = "refreshToken", EmitDefaultValue = true)]
        public string RefreshToken { 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 AuthenticateResponse {\n");
            sb.Append("  UserId: ").Append(UserId).Append("\n");
            sb.Append("  Email: ").Append(Email).Append("\n");
            sb.Append("  Roles: ").Append(Roles).Append("\n");
            sb.Append("  Token: ").Append(Token).Append("\n");
            sb.Append("  TokenType: ").Append(TokenType).Append("\n");
            sb.Append("  Expires: ").Append(Expires).Append("\n");
            sb.Append("  ValidUntil: ").Append(ValidUntil).Append("\n");
            sb.Append("  RefreshToken: ").Append(RefreshToken).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>
        /// 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 AuthenticateResponse);
        }

        /// <summary>
        /// Returns true if AuthenticateResponse instances are equal
        /// </summary>
        /// <param name="input">Instance of AuthenticateResponse to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(AuthenticateResponse input)
        {
            if (input == null)
            {
                return false;
            }
            return 
                (
                    this.UserId == input.UserId ||
                    (this.UserId != null &&
                    this.UserId.Equals(input.UserId))
                ) && 
                (
                    this.Email == input.Email ||
                    (this.Email != null &&
                    this.Email.Equals(input.Email))
                ) && 
                (
                    this.Roles == input.Roles ||
                    this.Roles != null &&
                    input.Roles != null &&
                    this.Roles.SequenceEqual(input.Roles)
                ) && 
                (
                    this.Token == input.Token ||
                    (this.Token != null &&
                    this.Token.Equals(input.Token))
                ) && 
                (
                    this.TokenType == input.TokenType ||
                    (this.TokenType != null &&
                    this.TokenType.Equals(input.TokenType))
                ) && 
                (
                    this.Expires == input.Expires ||
                    this.Expires.Equals(input.Expires)
                ) && 
                (
                    this.ValidUntil == input.ValidUntil ||
                    (this.ValidUntil != null &&
                    this.ValidUntil.Equals(input.ValidUntil))
                ) && 
                (
                    this.RefreshToken == input.RefreshToken ||
                    (this.RefreshToken != null &&
                    this.RefreshToken.Equals(input.RefreshToken))
                );
        }

        /// <summary>
        /// Gets the hash code
        /// </summary>
        /// <returns>Hash code</returns>
        public override int GetHashCode()
        {
            unchecked // Overflow is fine, just wrap
            {
                int hashCode = 41;
                if (this.UserId != null)
                {
                    hashCode = (hashCode * 59) + this.UserId.GetHashCode();
                }
                if (this.Email != null)
                {
                    hashCode = (hashCode * 59) + this.Email.GetHashCode();
                }
                if (this.Roles != null)
                {
                    hashCode = (hashCode * 59) + this.Roles.GetHashCode();
                }
                if (this.Token != null)
                {
                    hashCode = (hashCode * 59) + this.Token.GetHashCode();
                }
                if (this.TokenType != null)
                {
                    hashCode = (hashCode * 59) + this.TokenType.GetHashCode();
                }
                hashCode = (hashCode * 59) + this.Expires.GetHashCode();
                if (this.ValidUntil != null)
                {
                    hashCode = (hashCode * 59) + this.ValidUntil.GetHashCode();
                }
                if (this.RefreshToken != null)
                {
                    hashCode = (hashCode * 59) + this.RefreshToken.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)
        {
            // Token (string) minLength
            if (this.Token != null && this.Token.Length < 1)
            {
                yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Token, length must be greater than 1.", new [] { "Token" });
            }

            yield break;
        }
    }

}
