csharp/Adyen/adyen-dotnet-api-library/Adyen/Model/Checkout/Installments2.cs

Installments2.cs
#region Licence

// 
//                        ######
//                        ######
//  ############    ####( ######  #####. ######  ############   ############
//  #############  #####( ######  #####. ######  #############  #############
//         ######  #####( ######  #####. ######  #####  ######  #####  ######
//  ###### ######  #####( ######  #####. ######  #####  #####   #####  ######
//  ###### ######  #####( ######  #####. ######  #####          #####  ######
//  #############  #############  #############  #############  #####  ######
//   ############   ############  #############   ############  #####  ######
//                                       ######
//                                #############
//                                ############
// 
//  Adyen Dotnet API Library
// 
//  Copyright (c) 2020 Adyen B.V.
//  This file is open source and available under the MIT license.
//  See the LICENSE file for more info.

#endregion

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.IO;
using System.Runtime.Serialization;
using System.Text;
using Newtonsoft.Json;

namespace Adyen.Model.Checkout
{
    /// 
    /// Installments2
    /// 
    [DataContract]
    public partial clast Installments2 : IEquatable, IValidatableObject
    {
        /// 
        /// Initializes a new instance of the  clast.
        /// 
        /// Maximum number of installments (required).
        public Installments2(int? maxNumberOfInstallments = default(int?))
        {
            // to ensure "maxNumberOfInstallments" is required (not null)
            if (maxNumberOfInstallments == null)
            {
                throw new InvalidDataException(
                    "maxNumberOfInstallments is a required property for Installments2 and cannot be null");
            }
            else
            {
                this.MaxNumberOfInstallments = maxNumberOfInstallments;
            }
        }

        /// 
        /// Maximum number of installments
        /// 
        /// Maximum number of installments
        [DataMember(Name = "maxNumberOfInstallments", EmitDefaultValue = false)]
        public int? MaxNumberOfInstallments { get; set; }

        /// 
        /// Returns the string presentation of the object
        /// 
        /// String presentation of the object
        public override string ToString()
        {
            var sb = new StringBuilder();
            sb.Append("clast Installments2 {\n");
            sb.Append("  MaxNumberOfInstallments: ").Append(MaxNumberOfInstallments).Append("\n");
            sb.Append("}\n");
            return sb.ToString();
        }

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

        /// 
        /// Returns true if objects are equal
        /// 
        /// Object to be compared
        /// Boolean
        public override bool Equals(object input)
        {
            return this.Equals(input as Installments2);
        }

        /// 
        /// Returns true if Installments2 instances are equal
        /// 
        /// Instance of Installments2 to be compared
        /// Boolean
        public bool Equals(Installments2 input)
        {
            if (input == null)
                return false;

            return
                this.MaxNumberOfInstallments == input.MaxNumberOfInstallments ||
                this.MaxNumberOfInstallments != null &&
                this.MaxNumberOfInstallments.Equals(input.MaxNumberOfInstallments);
        }

        /// 
        /// Gets the hash code
        /// 
        /// Hash code
        public override int GetHashCode()
        {
            unchecked // Overflow is fine, just wrap
            {
                int hashCode = 41;
                if (this.MaxNumberOfInstallments != null)
                    hashCode = hashCode * 59 + this.MaxNumberOfInstallments.GetHashCode();
                return hashCode;
            }
        }

        /// 
        /// To validate all properties of the instance
        /// 
        /// Validation context
        /// Validation Result
        IEnumerable IValidatableObject.Validate(
            ValidationContext validationContext)
        {
            yield break;
        }
    }
}