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

LineItem.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.Runtime.Serialization;
using System.Text;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace Adyen.Model.Checkout
{
    /// 
    /// LineItem
    /// 
    [DataContract]
    public partial clast LineItem : IEquatable, IValidatableObject
    {
        /// 
        /// Required for AfterPay. Tax category: High, Low, None, Zero
        /// 
        /// Required for AfterPay. Tax category: High, Low, None, Zero
        [JsonConverter(typeof(StringEnumConverter))]
        public enum TaxCategoryEnum
        {
            /// 
            /// Enum High for value: High
            /// 
            [EnumMember(Value = "High")] High = 1,

            /// 
            /// Enum Low for value: Low
            /// 
            [EnumMember(Value = "Low")] Low = 2,

            /// 
            /// Enum None for value: None
            /// 
            [EnumMember(Value = "None")] None = 3,

            /// 
            /// Enum Zero for value: Zero
            /// 
            [EnumMember(Value = "Zero")] Zero = 4
        }

        /// 
        /// Required for AfterPay. Tax category: High, Low, None, Zero
        /// 
        /// Required for AfterPay. Tax category: High, Low, None, Zero
        [DataMember(Name = "taxCategory", EmitDefaultValue = false)]
        public TaxCategoryEnum? TaxCategory { get; set; }

        /// 
        /// Initializes a new instance of the  clast.
        /// 
        /// Item amount excluding the tax, in minor units..
        /// Item amount including the tax, in minor units..
        /// Description of the line item..
        /// ID of the line item..
        /// Link to the picture of the purchased item..
        /// Link to the purchased item..
        /// Number of items..
        /// Tax amount, in minor units..
        /// Required for AfterPay. Tax category: High, Low, None, Zero.
        /// Tax percentage, in minor units..
        public LineItem(long? amountExcludingTax = default(long?), long? amountIncludingTax = default(long?),
            string description = default(string), string id = default(string), string imageUrl = default(string),
            string productUrl = default(string), long? quansaty = default(long?), long? taxAmount = default(long?),
            TaxCategoryEnum? taxCategory = default(TaxCategoryEnum?), long? taxPercentage = default(long?))
        {
            this.AmountExcludingTax = amountExcludingTax;
            this.AmountIncludingTax = amountIncludingTax;
            this.Description = description;
            this.Id = id;
            this.ImageUrl = imageUrl;
            this.ProductUrl = productUrl;
            this.Quansaty = quansaty;
            this.TaxAmount = taxAmount;
            this.TaxCategory = taxCategory;
            this.TaxPercentage = taxPercentage;
        }

        /// 
        /// Item amount excluding the tax, in minor units.
        /// 
        /// Item amount excluding the tax, in minor units.
        [DataMember(Name = "amountExcludingTax", EmitDefaultValue = false)]
        public long? AmountExcludingTax { get; set; }

        /// 
        /// Item amount including the tax, in minor units.
        /// 
        /// Item amount including the tax, in minor units.
        [DataMember(Name = "amountIncludingTax", EmitDefaultValue = false)]
        public long? AmountIncludingTax { get; set; }

        /// 
        /// Description of the line item.
        /// 
        /// Description of the line item.
        [DataMember(Name = "description", EmitDefaultValue = false)]
        public string Description { get; set; }

        /// 
        /// ID of the line item.
        /// 
        /// ID of the line item.
        [DataMember(Name = "id", EmitDefaultValue = false)]
        public string Id { get; set; }

        /// 
        /// Link to the picture of the purchased item.
        /// 
        /// Link to the picture of the purchased item.
        [DataMember(Name = "imageUrl", EmitDefaultValue = false)]
        public string ImageUrl { get; set; }

        /// 
        /// Link to the purchased item.
        /// 
        /// Link to the purchased item.
        [DataMember(Name = "productUrl", EmitDefaultValue = false)]
        public string ProductUrl { get; set; }

        /// 
        /// Number of items.
        /// 
        /// Number of items.
        [DataMember(Name = "quansaty", EmitDefaultValue = false)]
        public long? Quansaty { get; set; }

        /// 
        /// Tax amount, in minor units.
        /// 
        /// Tax amount, in minor units.
        [DataMember(Name = "taxAmount", EmitDefaultValue = false)]
        public long? TaxAmount { get; set; }


        /// 
        /// Tax percentage, in minor units.
        /// 
        /// Tax percentage, in minor units.
        [DataMember(Name = "taxPercentage", EmitDefaultValue = false)]
        public long? TaxPercentage { 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 LineItem {\n");
            sb.Append("  AmountExcludingTax: ").Append(AmountExcludingTax).Append("\n");
            sb.Append("  AmountIncludingTax: ").Append(AmountIncludingTax).Append("\n");
            sb.Append("  Description: ").Append(Description).Append("\n");
            sb.Append("  Id: ").Append(Id).Append("\n");
            sb.Append("  ImageUrl: ").Append(ImageUrl).Append("\n");
            sb.Append("  ProductUrl: ").Append(ProductUrl).Append("\n");
            sb.Append("  Quansaty: ").Append(Quansaty).Append("\n");
            sb.Append("  TaxAmount: ").Append(TaxAmount).Append("\n");
            sb.Append("  TaxCategory: ").Append(TaxCategory).Append("\n");
            sb.Append("  TaxPercentage: ").Append(TaxPercentage).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 LineItem);
        }

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

            return
                (
                    this.AmountExcludingTax == input.AmountExcludingTax ||
                    this.AmountExcludingTax != null &&
                    this.AmountExcludingTax.Equals(input.AmountExcludingTax)
                ) &&
                (
                    this.AmountIncludingTax == input.AmountIncludingTax ||
                    this.AmountIncludingTax != null &&
                    this.AmountIncludingTax.Equals(input.AmountIncludingTax)
                ) &&
                (
                    this.Description == input.Description ||
                    this.Description != null &&
                    this.Description.Equals(input.Description)
                ) &&
                (
                    this.Id == input.Id ||
                    this.Id != null &&
                    this.Id.Equals(input.Id)
                ) &&
                (
                    this.ImageUrl == input.ImageUrl ||
                    this.ImageUrl != null &&
                    this.ImageUrl.Equals(input.ImageUrl)
                ) &&
                (
                    this.ProductUrl == input.ProductUrl ||
                    this.ProductUrl != null &&
                    this.ProductUrl.Equals(input.ProductUrl)
                ) &&
                (
                    this.Quansaty == input.Quansaty ||
                    this.Quansaty != null &&
                    this.Quansaty.Equals(input.Quansaty)
                ) &&
                (
                    this.TaxAmount == input.TaxAmount ||
                    this.TaxAmount != null &&
                    this.TaxAmount.Equals(input.TaxAmount)
                ) &&
                (
                    this.TaxCategory == input.TaxCategory ||
                    this.TaxCategory != null &&
                    this.TaxCategory.Equals(input.TaxCategory)
                ) &&
                (
                    this.TaxPercentage == input.TaxPercentage ||
                    this.TaxPercentage != null &&
                    this.TaxPercentage.Equals(input.TaxPercentage)
                );
        }

        /// 
        /// Gets the hash code
        /// 
        /// Hash code
        public override int GetHashCode()
        {
            unchecked // Overflow is fine, just wrap
            {
                int hashCode = 41;
                if (this.AmountExcludingTax != null)
                    hashCode = hashCode * 59 + this.AmountExcludingTax.GetHashCode();
                if (this.AmountIncludingTax != null)
                    hashCode = hashCode * 59 + this.AmountIncludingTax.GetHashCode();
                if (this.Description != null)
                    hashCode = hashCode * 59 + this.Description.GetHashCode();
                if (this.Id != null)
                    hashCode = hashCode * 59 + this.Id.GetHashCode();
                if (this.ImageUrl != null)
                    hashCode = hashCode * 59 + this.ImageUrl.GetHashCode();
                if (this.ProductUrl != null)
                    hashCode = hashCode * 59 + this.ProductUrl.GetHashCode();
                if (this.Quansaty != null)
                    hashCode = hashCode * 59 + this.Quansaty.GetHashCode();
                if (this.TaxAmount != null)
                    hashCode = hashCode * 59 + this.TaxAmount.GetHashCode();
                if (this.TaxCategory != null)
                    hashCode = hashCode * 59 + this.TaxCategory.GetHashCode();
                if (this.TaxPercentage != null)
                    hashCode = hashCode * 59 + this.TaxPercentage.GetHashCode();
                return hashCode;
            }
        }

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