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

InstallmentOption.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.Linq;
using System.Runtime.Serialization;
using System.Text;
using Adyen.Util;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace Adyen.Model.Checkout
{
    /// 
    /// InstallmentOption
    /// 
    [DataContract]
    public partial clast InstallmentOption : IEquatable, IValidatableObject
    {
        /// 
        /// Defines Plans
        /// 
        [JsonConverter(typeof(StringEnumConverter))]
        public enum PlansEnum
        {
            /// 
            /// Enum Regular for value: regular
            /// 
            [EnumMember(Value = "regular")] Regular = 1,

            /// 
            /// Enum Revolving for value: revolving
            /// 
            [EnumMember(Value = "revolving")] Revolving = 2
        }

        /// 
        /// Defines the type of installment plan. If not set, defaults to **regular**.  Possible values: * **regular** * **revolving**
        /// 
        /// Defines the type of installment plan. If not set, defaults to **regular**.  Possible values: * **regular** * **revolving**
        [DataMember(Name = "plans", EmitDefaultValue = false)]
        public List Plans { get; set; }

        /// 
        /// Initializes a new instance of the  clast.
        /// 
        /// The maximum number of installments offered for this payment method..
        /// Defines the type of installment plan. If not set, defaults to **regular**.  Possible values: * **regular** * **revolving**.
        public InstallmentOption(int? maxValue = default(int?), List plans = default(List))
        {
            this.MaxValue = maxValue;
            this.Plans = plans;
        }

        /// 
        /// The maximum number of installments offered for this payment method.
        /// 
        /// The maximum number of installments offered for this payment method.
        [DataMember(Name = "maxValue", EmitDefaultValue = false)]
        public int? MaxValue { 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 InstallmentOption {\n");
            sb.Append("  MaxValue: ").Append(MaxValue).Append("\n");
            sb.Append("  Plans: ").Append(Plans.ObjectListToString()).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 InstallmentOption);
        }

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

            return
                (
                    this.MaxValue == input.MaxValue ||
                    this.MaxValue != null &&
                    this.MaxValue.Equals(input.MaxValue)
                ) &&
                (
                    this.Plans == input.Plans ||
                    this.Plans != null &&
                    input.Plans != null &&
                    this.Plans.SequenceEqual(input.Plans)
                );
        }

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

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