All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.zuora.model.CreateDiscountItem Maven / Gradle / Ivy

There is a newer version: 3.2.1
Show newest version
/*
 * Zuora API Reference
 * REST API reference for the Zuora Billing, Payments, and Central Platform! Check out the [REST API Overview](https://www.zuora.com/developer/api-references/api/overview/).
 *
 * The version of the OpenAPI document: 2024-05-20
 * Contact: [email protected]
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */


package com.zuora.model;

import java.util.Objects;
import com.google.gson.TypeAdapter;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.annotations.SerializedName;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import com.zuora.model.CreateTaxationItem;
import com.zuora.model.RevRecTrigger;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.TypeAdapterFactory;
import com.google.gson.reflect.TypeToken;
import com.google.gson.TypeAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

import com.zuora.JSON;

/**
 * CreateDiscountItem
 */
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.6.0")
public class CreateDiscountItem {
  public static final String SERIALIZED_NAME_INTEGRATION_ID_N_S = "IntegrationId__NS";
  @SerializedName(SERIALIZED_NAME_INTEGRATION_ID_N_S)
  private String integrationIdNS;

  public static final String SERIALIZED_NAME_INTEGRATION_STATUS_N_S = "IntegrationStatus__NS";
  @SerializedName(SERIALIZED_NAME_INTEGRATION_STATUS_N_S)
  private String integrationStatusNS;

  public static final String SERIALIZED_NAME_SYNC_DATE_N_S = "SyncDate__NS";
  @SerializedName(SERIALIZED_NAME_SYNC_DATE_N_S)
  private String syncDateNS;

  public static final String SERIALIZED_NAME_ACCOUNTING_CODE = "accountingCode";
  @SerializedName(SERIALIZED_NAME_ACCOUNTING_CODE)
  private String accountingCode;

  public static final String SERIALIZED_NAME_ACCOUNTS_RECEIVABLE_ACCOUNTING_CODE = "accountsReceivableAccountingCode";
  @SerializedName(SERIALIZED_NAME_ACCOUNTS_RECEIVABLE_ACCOUNTING_CODE)
  private String accountsReceivableAccountingCode;

  public static final String SERIALIZED_NAME_ADJUSTMENT_LIABILITY_ACCOUNTING_CODE = "adjustmentLiabilityAccountingCode";
  @SerializedName(SERIALIZED_NAME_ADJUSTMENT_LIABILITY_ACCOUNTING_CODE)
  private String adjustmentLiabilityAccountingCode;

  public static final String SERIALIZED_NAME_ADJUSTMENT_REVENUE_ACCOUNTING_CODE = "adjustmentRevenueAccountingCode";
  @SerializedName(SERIALIZED_NAME_ADJUSTMENT_REVENUE_ACCOUNTING_CODE)
  private String adjustmentRevenueAccountingCode;

  public static final String SERIALIZED_NAME_AMOUNT = "amount";
  @SerializedName(SERIALIZED_NAME_AMOUNT)
  private BigDecimal amount;

  public static final String SERIALIZED_NAME_BOOKING_REFERENCE = "bookingReference";
  @SerializedName(SERIALIZED_NAME_BOOKING_REFERENCE)
  private String bookingReference;

  public static final String SERIALIZED_NAME_CHARGE_DATE = "chargeDate";
  @SerializedName(SERIALIZED_NAME_CHARGE_DATE)
  private String chargeDate;

  public static final String SERIALIZED_NAME_CHARGE_NAME = "chargeName";
  @SerializedName(SERIALIZED_NAME_CHARGE_NAME)
  private String chargeName;

  public static final String SERIALIZED_NAME_CONTRACT_ASSET_ACCOUNTING_CODE = "contractAssetAccountingCode";
  @SerializedName(SERIALIZED_NAME_CONTRACT_ASSET_ACCOUNTING_CODE)
  private String contractAssetAccountingCode;

  public static final String SERIALIZED_NAME_CONTRACT_LIABILITY_ACCOUNTING_CODE = "contractLiabilityAccountingCode";
  @SerializedName(SERIALIZED_NAME_CONTRACT_LIABILITY_ACCOUNTING_CODE)
  private String contractLiabilityAccountingCode;

  public static final String SERIALIZED_NAME_CONTRACT_RECOGNIZED_REVENUE_ACCOUNTING_CODE = "contractRecognizedRevenueAccountingCode";
  @SerializedName(SERIALIZED_NAME_CONTRACT_RECOGNIZED_REVENUE_ACCOUNTING_CODE)
  private String contractRecognizedRevenueAccountingCode;

  public static final String SERIALIZED_NAME_DEFERRED_REVENUE_ACCOUNTING_CODE = "deferredRevenueAccountingCode";
  @SerializedName(SERIALIZED_NAME_DEFERRED_REVENUE_ACCOUNTING_CODE)
  private String deferredRevenueAccountingCode;

  public static final String SERIALIZED_NAME_DESCRIPTION = "description";
  @SerializedName(SERIALIZED_NAME_DESCRIPTION)
  private String description;

  public static final String SERIALIZED_NAME_ITEM_TYPE = "itemType";
  @SerializedName(SERIALIZED_NAME_ITEM_TYPE)
  private String itemType;

  public static final String SERIALIZED_NAME_PRODUCT_RATE_PLAN_CHARGE_ID = "productRatePlanChargeId";
  @SerializedName(SERIALIZED_NAME_PRODUCT_RATE_PLAN_CHARGE_ID)
  private String productRatePlanChargeId;

  public static final String SERIALIZED_NAME_PURCHASE_ORDER_NUMBER = "purchaseOrderNumber";
  @SerializedName(SERIALIZED_NAME_PURCHASE_ORDER_NUMBER)
  private String purchaseOrderNumber;

  public static final String SERIALIZED_NAME_RECOGNIZED_REVENUE_ACCOUNTING_CODE = "recognizedRevenueAccountingCode";
  @SerializedName(SERIALIZED_NAME_RECOGNIZED_REVENUE_ACCOUNTING_CODE)
  private String recognizedRevenueAccountingCode;

  public static final String SERIALIZED_NAME_REV_REC_CODE = "revRecCode";
  @SerializedName(SERIALIZED_NAME_REV_REC_CODE)
  private String revRecCode;

  public static final String SERIALIZED_NAME_REV_REC_TRIGGER_CONDITION = "revRecTriggerCondition";
  @SerializedName(SERIALIZED_NAME_REV_REC_TRIGGER_CONDITION)
  private RevRecTrigger revRecTriggerCondition;

  public static final String SERIALIZED_NAME_REVENUE_RECOGNITION_RULE_NAME = "revenueRecognitionRuleName";
  @SerializedName(SERIALIZED_NAME_REVENUE_RECOGNITION_RULE_NAME)
  private String revenueRecognitionRuleName;

  public static final String SERIALIZED_NAME_SKU = "sku";
  @SerializedName(SERIALIZED_NAME_SKU)
  private String sku;

  public static final String SERIALIZED_NAME_TAX_ITEMS = "taxItems";
  @SerializedName(SERIALIZED_NAME_TAX_ITEMS)
  private List taxItems;

  public static final String SERIALIZED_NAME_UNBILLED_RECEIVABLES_ACCOUNTING_CODE = "unbilledReceivablesAccountingCode";
  @SerializedName(SERIALIZED_NAME_UNBILLED_RECEIVABLES_ACCOUNTING_CODE)
  private String unbilledReceivablesAccountingCode;

  public static final String SERIALIZED_NAME_UNIT_PRICE = "unitPrice";
  @SerializedName(SERIALIZED_NAME_UNIT_PRICE)
  private BigDecimal unitPrice;

  public CreateDiscountItem() {
  }

  public CreateDiscountItem integrationIdNS(String integrationIdNS) {
    this.integrationIdNS = integrationIdNS;
    return this;
  }

  /**
   * ID of the corresponding object in NetSuite. Only available if you have installed the [Zuora Connector for NetSuite](https://www.zuora.com/connect/app/?appId=265). 
   * @return integrationIdNS
   */
  @javax.annotation.Nullable
  public String getIntegrationIdNS() {
    return integrationIdNS;
  }

  public void setIntegrationIdNS(String integrationIdNS) {
    this.integrationIdNS = integrationIdNS;
  }


  public CreateDiscountItem integrationStatusNS(String integrationStatusNS) {
    this.integrationStatusNS = integrationStatusNS;
    return this;
  }

  /**
   * Status of the invoice item's synchronization with NetSuite. Only available if you have installed the [Zuora Connector for NetSuite](https://www.zuora.com/connect/app/?appId=265). 
   * @return integrationStatusNS
   */
  @javax.annotation.Nullable
  public String getIntegrationStatusNS() {
    return integrationStatusNS;
  }

  public void setIntegrationStatusNS(String integrationStatusNS) {
    this.integrationStatusNS = integrationStatusNS;
  }


  public CreateDiscountItem syncDateNS(String syncDateNS) {
    this.syncDateNS = syncDateNS;
    return this;
  }

  /**
   * Date when the invoice item was synchronized with NetSuite. Only available if you have installed the [Zuora Connector for NetSuite](https://www.zuora.com/connect/app/?appId=265). 
   * @return syncDateNS
   */
  @javax.annotation.Nullable
  public String getSyncDateNS() {
    return syncDateNS;
  }

  public void setSyncDateNS(String syncDateNS) {
    this.syncDateNS = syncDateNS;
  }


  public CreateDiscountItem accountingCode(String accountingCode) {
    this.accountingCode = accountingCode;
    return this;
  }

  /**
   * The accounting code associated with the discount item. 
   * @return accountingCode
   */
  @javax.annotation.Nullable
  public String getAccountingCode() {
    return accountingCode;
  }

  public void setAccountingCode(String accountingCode) {
    this.accountingCode = accountingCode;
  }


  public CreateDiscountItem accountsReceivableAccountingCode(String accountsReceivableAccountingCode) {
    this.accountsReceivableAccountingCode = accountsReceivableAccountingCode;
    return this;
  }

  /**
   * The accounting code for accounts receivable. 
   * @return accountsReceivableAccountingCode
   */
  @javax.annotation.Nullable
  public String getAccountsReceivableAccountingCode() {
    return accountsReceivableAccountingCode;
  }

  public void setAccountsReceivableAccountingCode(String accountsReceivableAccountingCode) {
    this.accountsReceivableAccountingCode = accountsReceivableAccountingCode;
  }


  public CreateDiscountItem adjustmentLiabilityAccountingCode(String adjustmentLiabilityAccountingCode) {
    this.adjustmentLiabilityAccountingCode = adjustmentLiabilityAccountingCode;
    return this;
  }

  /**
   * The accounting code for adjustment liability. **Note**: This field is only available if you have the Billing - Revenue Integration feature enabled. 
   * @return adjustmentLiabilityAccountingCode
   */
  @javax.annotation.Nullable
  public String getAdjustmentLiabilityAccountingCode() {
    return adjustmentLiabilityAccountingCode;
  }

  public void setAdjustmentLiabilityAccountingCode(String adjustmentLiabilityAccountingCode) {
    this.adjustmentLiabilityAccountingCode = adjustmentLiabilityAccountingCode;
  }


  public CreateDiscountItem adjustmentRevenueAccountingCode(String adjustmentRevenueAccountingCode) {
    this.adjustmentRevenueAccountingCode = adjustmentRevenueAccountingCode;
    return this;
  }

  /**
   * The accounting code for adjustment revenue. **Note**: This field is only available if you have the Billing - Revenue Integration feature enabled. 
   * @return adjustmentRevenueAccountingCode
   */
  @javax.annotation.Nullable
  public String getAdjustmentRevenueAccountingCode() {
    return adjustmentRevenueAccountingCode;
  }

  public void setAdjustmentRevenueAccountingCode(String adjustmentRevenueAccountingCode) {
    this.adjustmentRevenueAccountingCode = adjustmentRevenueAccountingCode;
  }


  public CreateDiscountItem amount(BigDecimal amount) {
    this.amount = amount;
    return this;
  }

  /**
   * The amount of the discount item. - Should be a negative number. For example, `-10`. - Always a fixed amount no matter whether the discount charge associated with the discount item uses the [fixed-amount model or percentage model](https://knowledgecenter.zuora.com/Billing/Subscriptions/Product_Catalog/B_Charge_Models/B_Discount_Charge_Models#Fixed_amount_model_and_percentage_model). - For tax-exclusive discount items, this amount indicates the discount item amount excluding tax. - For tax-inclusive discount items, this amount indicates the discount item amount including tax. 
   * @return amount
   */
  @javax.annotation.Nonnull
  public BigDecimal getAmount() {
    return amount;
  }

  public void setAmount(BigDecimal amount) {
    this.amount = amount;
  }


  public CreateDiscountItem bookingReference(String bookingReference) {
    this.bookingReference = bookingReference;
    return this;
  }

  /**
   * The booking reference of the discount item. 
   * @return bookingReference
   */
  @javax.annotation.Nullable
  public String getBookingReference() {
    return bookingReference;
  }

  public void setBookingReference(String bookingReference) {
    this.bookingReference = bookingReference;
  }


  public CreateDiscountItem chargeDate(String chargeDate) {
    this.chargeDate = chargeDate;
    return this;
  }

  /**
   * The date when the discount item is charged, in `yyyy-mm-dd hh:mm:ss` format.
   * @return chargeDate
   */
  @javax.annotation.Nullable
  public String getChargeDate() {
    return chargeDate;
  }

  public void setChargeDate(String chargeDate) {
    this.chargeDate = chargeDate;
  }


  public CreateDiscountItem chargeName(String chargeName) {
    this.chargeName = chargeName;
    return this;
  }

  /**
   * The name of the charge associated with the discount item. This field is required if the `productRatePlanChargeId` field is not specified in the request body. 
   * @return chargeName
   */
  @javax.annotation.Nullable
  public String getChargeName() {
    return chargeName;
  }

  public void setChargeName(String chargeName) {
    this.chargeName = chargeName;
  }


  public CreateDiscountItem contractAssetAccountingCode(String contractAssetAccountingCode) {
    this.contractAssetAccountingCode = contractAssetAccountingCode;
    return this;
  }

  /**
   * The accounting code for contract asset. **Note**: This field is only available if you have the Billing - Revenue Integration feature enabled. 
   * @return contractAssetAccountingCode
   */
  @javax.annotation.Nullable
  public String getContractAssetAccountingCode() {
    return contractAssetAccountingCode;
  }

  public void setContractAssetAccountingCode(String contractAssetAccountingCode) {
    this.contractAssetAccountingCode = contractAssetAccountingCode;
  }


  public CreateDiscountItem contractLiabilityAccountingCode(String contractLiabilityAccountingCode) {
    this.contractLiabilityAccountingCode = contractLiabilityAccountingCode;
    return this;
  }

  /**
   * The accounting code for contract liability. **Note**: This field is only available if you have the Billing - Revenue Integration feature enabled. 
   * @return contractLiabilityAccountingCode
   */
  @javax.annotation.Nullable
  public String getContractLiabilityAccountingCode() {
    return contractLiabilityAccountingCode;
  }

  public void setContractLiabilityAccountingCode(String contractLiabilityAccountingCode) {
    this.contractLiabilityAccountingCode = contractLiabilityAccountingCode;
  }


  public CreateDiscountItem contractRecognizedRevenueAccountingCode(String contractRecognizedRevenueAccountingCode) {
    this.contractRecognizedRevenueAccountingCode = contractRecognizedRevenueAccountingCode;
    return this;
  }

  /**
   * The accounting code for contract recognized revenue. **Note**: This field is only available if you have the Billing - Revenue Integration feature enabled. 
   * @return contractRecognizedRevenueAccountingCode
   */
  @javax.annotation.Nullable
  public String getContractRecognizedRevenueAccountingCode() {
    return contractRecognizedRevenueAccountingCode;
  }

  public void setContractRecognizedRevenueAccountingCode(String contractRecognizedRevenueAccountingCode) {
    this.contractRecognizedRevenueAccountingCode = contractRecognizedRevenueAccountingCode;
  }


  public CreateDiscountItem deferredRevenueAccountingCode(String deferredRevenueAccountingCode) {
    this.deferredRevenueAccountingCode = deferredRevenueAccountingCode;
    return this;
  }

  /**
   * The accounting code for the deferred revenue, such as Monthly Recurring Liability. **Note:** This field is only available if you have Zuora Finance enabled. 
   * @return deferredRevenueAccountingCode
   */
  @javax.annotation.Nullable
  public String getDeferredRevenueAccountingCode() {
    return deferredRevenueAccountingCode;
  }

  public void setDeferredRevenueAccountingCode(String deferredRevenueAccountingCode) {
    this.deferredRevenueAccountingCode = deferredRevenueAccountingCode;
  }


  public CreateDiscountItem description(String description) {
    this.description = description;
    return this;
  }

  /**
   * The description of the discount item. 
   * @return description
   */
  @javax.annotation.Nullable
  public String getDescription() {
    return description;
  }

  public void setDescription(String description) {
    this.description = description;
  }


  public CreateDiscountItem itemType(String itemType) {
    this.itemType = itemType;
    return this;
  }

  /**
   * The type of the discount item. 
   * @return itemType
   */
  @javax.annotation.Nullable
  public String getItemType() {
    return itemType;
  }

  public void setItemType(String itemType) {
    this.itemType = itemType;
  }


  public CreateDiscountItem productRatePlanChargeId(String productRatePlanChargeId) {
    this.productRatePlanChargeId = productRatePlanChargeId;
    return this;
  }

  /**
   * The ID of the product rate plan charge that the discount item is created from.  If you specify a value for the `productRatePlanChargeId` field in the request, Zuora directly copies the values of the following fields from the corresponding product rate plan charge, regardless of the values specified in the request body: - `chargeName` - `sku`  If you specify a value for the `productRatePlanChargeId` field in the request, Zuora directly copies the values of the following fields from the corresponding discount charge that [uses discount specific accounting codes, rule and segment to manage revenue](https://knowledgecenter.zuora.com/Billing/Subscriptions/Product_Catalog/B_Charge_Models/Manage_Discount_Charges#Use_discount_specific_accounting_codes.2C_rule_and_segment_to_manage_revenue), regardless of the values specified in the request body: - `accountingCode` - `deferredRevenueAccountingCode` - `recognizedRevenueAccountingCode`  If you specify a value for the `productRatePlanChargeId` field in the request, Zuora directly copies the values of the following fields from the corresponding invoice item charge if the discount charge DOES NOT [use discount specific accounting codes, rule and segment to manage revenue](https://knowledgecenter.zuora.com/Billing/Subscriptions/Product_Catalog/B_Charge_Models/Manage_Discount_Charges#Use_discount_specific_accounting_codes.2C_rule_and_segment_to_manage_revenue), regardless of the values specified in the request body: - `accountingCode` - `deferredRevenueAccountingCode` - `recognizedRevenueAccountingCode` 
   * @return productRatePlanChargeId
   */
  @javax.annotation.Nullable
  public String getProductRatePlanChargeId() {
    return productRatePlanChargeId;
  }

  public void setProductRatePlanChargeId(String productRatePlanChargeId) {
    this.productRatePlanChargeId = productRatePlanChargeId;
  }


  public CreateDiscountItem purchaseOrderNumber(String purchaseOrderNumber) {
    this.purchaseOrderNumber = purchaseOrderNumber;
    return this;
  }

  /**
   * The purchase order number associated with the discount item. 
   * @return purchaseOrderNumber
   */
  @javax.annotation.Nullable
  public String getPurchaseOrderNumber() {
    return purchaseOrderNumber;
  }

  public void setPurchaseOrderNumber(String purchaseOrderNumber) {
    this.purchaseOrderNumber = purchaseOrderNumber;
  }


  public CreateDiscountItem recognizedRevenueAccountingCode(String recognizedRevenueAccountingCode) {
    this.recognizedRevenueAccountingCode = recognizedRevenueAccountingCode;
    return this;
  }

  /**
   * The accounting code for the recognized revenue, such as Monthly Recurring Charges or Overage Charges. **Note:** This field is only available if you have Zuora Finance enabled. 
   * @return recognizedRevenueAccountingCode
   */
  @javax.annotation.Nullable
  public String getRecognizedRevenueAccountingCode() {
    return recognizedRevenueAccountingCode;
  }

  public void setRecognizedRevenueAccountingCode(String recognizedRevenueAccountingCode) {
    this.recognizedRevenueAccountingCode = recognizedRevenueAccountingCode;
  }


  public CreateDiscountItem revRecCode(String revRecCode) {
    this.revRecCode = revRecCode;
    return this;
  }

  /**
   * The revenue recognition code. 
   * @return revRecCode
   */
  @javax.annotation.Nullable
  public String getRevRecCode() {
    return revRecCode;
  }

  public void setRevRecCode(String revRecCode) {
    this.revRecCode = revRecCode;
  }


  public CreateDiscountItem revRecTriggerCondition(RevRecTrigger revRecTriggerCondition) {
    this.revRecTriggerCondition = revRecTriggerCondition;
    return this;
  }

  /**
   * Get revRecTriggerCondition
   * @return revRecTriggerCondition
   */
  @javax.annotation.Nullable
  public RevRecTrigger getRevRecTriggerCondition() {
    return revRecTriggerCondition;
  }

  public void setRevRecTriggerCondition(RevRecTrigger revRecTriggerCondition) {
    this.revRecTriggerCondition = revRecTriggerCondition;
  }


  public CreateDiscountItem revenueRecognitionRuleName(String revenueRecognitionRuleName) {
    this.revenueRecognitionRuleName = revenueRecognitionRuleName;
    return this;
  }

  /**
   * The name of the revenue recognition rule governing the revenue schedule. **Note:** This field is only available if you have Zuora Finance enabled. 
   * @return revenueRecognitionRuleName
   */
  @javax.annotation.Nullable
  public String getRevenueRecognitionRuleName() {
    return revenueRecognitionRuleName;
  }

  public void setRevenueRecognitionRuleName(String revenueRecognitionRuleName) {
    this.revenueRecognitionRuleName = revenueRecognitionRuleName;
  }


  public CreateDiscountItem sku(String sku) {
    this.sku = sku;
    return this;
  }

  /**
   * The SKU of the invoice item. The SKU of the discount item must be different from the SKU of any existing product. 
   * @return sku
   */
  @javax.annotation.Nullable
  public String getSku() {
    return sku;
  }

  public void setSku(String sku) {
    this.sku = sku;
  }


  public CreateDiscountItem taxItems(List taxItems) {
    this.taxItems = taxItems;
    return this;
  }

  public CreateDiscountItem addTaxItemsItem(CreateTaxationItem taxItemsItem) {
    if (this.taxItems == null) {
      this.taxItems = new ArrayList<>();
    }
    this.taxItems.add(taxItemsItem);
    return this;
  }

  /**
   * Container for taxation items. The maximum number of taxation items is 5.  **Note**: This field is only available only if you have Taxation enabled. 
   * @return taxItems
   */
  @javax.annotation.Nullable
  public List getTaxItems() {
    return taxItems;
  }

  public void setTaxItems(List taxItems) {
    this.taxItems = taxItems;
  }


  public CreateDiscountItem unbilledReceivablesAccountingCode(String unbilledReceivablesAccountingCode) {
    this.unbilledReceivablesAccountingCode = unbilledReceivablesAccountingCode;
    return this;
  }

  /**
   * The accounting code for unbilled receivables. **Note**: This field is only available if you have the Billing - Revenue Integration feature enabled. 
   * @return unbilledReceivablesAccountingCode
   */
  @javax.annotation.Nullable
  public String getUnbilledReceivablesAccountingCode() {
    return unbilledReceivablesAccountingCode;
  }

  public void setUnbilledReceivablesAccountingCode(String unbilledReceivablesAccountingCode) {
    this.unbilledReceivablesAccountingCode = unbilledReceivablesAccountingCode;
  }


  public CreateDiscountItem unitPrice(BigDecimal unitPrice) {
    this.unitPrice = unitPrice;
    return this;
  }

  /**
   * The per-unit price of the discount item. If the discount charge associated with the discount item uses the percentage model, the unit price will display as a percentage amount in PDF. For example: if unit price is 5.00, it will display as 5.00% in PDF. 
   * @return unitPrice
   */
  @javax.annotation.Nullable
  public BigDecimal getUnitPrice() {
    return unitPrice;
  }

  public void setUnitPrice(BigDecimal unitPrice) {
    this.unitPrice = unitPrice;
  }

  /**
   * A container for additional, undeclared properties.
   * This is a holder for any undeclared properties as specified with
   * the 'additionalProperties' keyword in the OAS document.
   */
  private Map additionalProperties;

  /**
   * Set the additional (undeclared) property with the specified name and value.
   * If the property does not already exist, create it otherwise replace it.
   *
   * @param key name of the property
   * @param value value of the property
   * @return the CreateDiscountItem instance itself
   */
  public CreateDiscountItem putAdditionalProperty(String key, Object value) {
    if (this.additionalProperties == null) {
        this.additionalProperties = new HashMap();
    }
    this.additionalProperties.put(key, value);
    return this;
  }

  /**
   * Return the additional (undeclared) property.
   *
   * @return a map of objects
   */
  public Map getAdditionalProperties() {
    return additionalProperties;
  }

  /**
   * Return the additional (undeclared) property with the specified name.
   *
   * @param key name of the property
   * @return an object
   */
  public Object getAdditionalProperty(String key) {
    if (this.additionalProperties == null) {
        return null;
    }
    return this.additionalProperties.get(key);
  }


  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    CreateDiscountItem createDiscountItem = (CreateDiscountItem) o;
    return Objects.equals(this.integrationIdNS, createDiscountItem.integrationIdNS) &&
        Objects.equals(this.integrationStatusNS, createDiscountItem.integrationStatusNS) &&
        Objects.equals(this.syncDateNS, createDiscountItem.syncDateNS) &&
        Objects.equals(this.accountingCode, createDiscountItem.accountingCode) &&
        Objects.equals(this.accountsReceivableAccountingCode, createDiscountItem.accountsReceivableAccountingCode) &&
        Objects.equals(this.adjustmentLiabilityAccountingCode, createDiscountItem.adjustmentLiabilityAccountingCode) &&
        Objects.equals(this.adjustmentRevenueAccountingCode, createDiscountItem.adjustmentRevenueAccountingCode) &&
        Objects.equals(this.amount, createDiscountItem.amount) &&
        Objects.equals(this.bookingReference, createDiscountItem.bookingReference) &&
        Objects.equals(this.chargeDate, createDiscountItem.chargeDate) &&
        Objects.equals(this.chargeName, createDiscountItem.chargeName) &&
        Objects.equals(this.contractAssetAccountingCode, createDiscountItem.contractAssetAccountingCode) &&
        Objects.equals(this.contractLiabilityAccountingCode, createDiscountItem.contractLiabilityAccountingCode) &&
        Objects.equals(this.contractRecognizedRevenueAccountingCode, createDiscountItem.contractRecognizedRevenueAccountingCode) &&
        Objects.equals(this.deferredRevenueAccountingCode, createDiscountItem.deferredRevenueAccountingCode) &&
        Objects.equals(this.description, createDiscountItem.description) &&
        Objects.equals(this.itemType, createDiscountItem.itemType) &&
        Objects.equals(this.productRatePlanChargeId, createDiscountItem.productRatePlanChargeId) &&
        Objects.equals(this.purchaseOrderNumber, createDiscountItem.purchaseOrderNumber) &&
        Objects.equals(this.recognizedRevenueAccountingCode, createDiscountItem.recognizedRevenueAccountingCode) &&
        Objects.equals(this.revRecCode, createDiscountItem.revRecCode) &&
        Objects.equals(this.revRecTriggerCondition, createDiscountItem.revRecTriggerCondition) &&
        Objects.equals(this.revenueRecognitionRuleName, createDiscountItem.revenueRecognitionRuleName) &&
        Objects.equals(this.sku, createDiscountItem.sku) &&
        Objects.equals(this.taxItems, createDiscountItem.taxItems) &&
        Objects.equals(this.unbilledReceivablesAccountingCode, createDiscountItem.unbilledReceivablesAccountingCode) &&
        Objects.equals(this.unitPrice, createDiscountItem.unitPrice)&&
        Objects.equals(this.additionalProperties, createDiscountItem.additionalProperties);
  }

  @Override
  public int hashCode() {
    return Objects.hash(integrationIdNS, integrationStatusNS, syncDateNS, accountingCode, accountsReceivableAccountingCode, adjustmentLiabilityAccountingCode, adjustmentRevenueAccountingCode, amount, bookingReference, chargeDate, chargeName, contractAssetAccountingCode, contractLiabilityAccountingCode, contractRecognizedRevenueAccountingCode, deferredRevenueAccountingCode, description, itemType, productRatePlanChargeId, purchaseOrderNumber, recognizedRevenueAccountingCode, revRecCode, revRecTriggerCondition, revenueRecognitionRuleName, sku, taxItems, unbilledReceivablesAccountingCode, unitPrice, additionalProperties);
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("class CreateDiscountItem {\n");
    sb.append("    integrationIdNS: ").append(toIndentedString(integrationIdNS)).append("\n");
    sb.append("    integrationStatusNS: ").append(toIndentedString(integrationStatusNS)).append("\n");
    sb.append("    syncDateNS: ").append(toIndentedString(syncDateNS)).append("\n");
    sb.append("    accountingCode: ").append(toIndentedString(accountingCode)).append("\n");
    sb.append("    accountsReceivableAccountingCode: ").append(toIndentedString(accountsReceivableAccountingCode)).append("\n");
    sb.append("    adjustmentLiabilityAccountingCode: ").append(toIndentedString(adjustmentLiabilityAccountingCode)).append("\n");
    sb.append("    adjustmentRevenueAccountingCode: ").append(toIndentedString(adjustmentRevenueAccountingCode)).append("\n");
    sb.append("    amount: ").append(toIndentedString(amount)).append("\n");
    sb.append("    bookingReference: ").append(toIndentedString(bookingReference)).append("\n");
    sb.append("    chargeDate: ").append(toIndentedString(chargeDate)).append("\n");
    sb.append("    chargeName: ").append(toIndentedString(chargeName)).append("\n");
    sb.append("    contractAssetAccountingCode: ").append(toIndentedString(contractAssetAccountingCode)).append("\n");
    sb.append("    contractLiabilityAccountingCode: ").append(toIndentedString(contractLiabilityAccountingCode)).append("\n");
    sb.append("    contractRecognizedRevenueAccountingCode: ").append(toIndentedString(contractRecognizedRevenueAccountingCode)).append("\n");
    sb.append("    deferredRevenueAccountingCode: ").append(toIndentedString(deferredRevenueAccountingCode)).append("\n");
    sb.append("    description: ").append(toIndentedString(description)).append("\n");
    sb.append("    itemType: ").append(toIndentedString(itemType)).append("\n");
    sb.append("    productRatePlanChargeId: ").append(toIndentedString(productRatePlanChargeId)).append("\n");
    sb.append("    purchaseOrderNumber: ").append(toIndentedString(purchaseOrderNumber)).append("\n");
    sb.append("    recognizedRevenueAccountingCode: ").append(toIndentedString(recognizedRevenueAccountingCode)).append("\n");
    sb.append("    revRecCode: ").append(toIndentedString(revRecCode)).append("\n");
    sb.append("    revRecTriggerCondition: ").append(toIndentedString(revRecTriggerCondition)).append("\n");
    sb.append("    revenueRecognitionRuleName: ").append(toIndentedString(revenueRecognitionRuleName)).append("\n");
    sb.append("    sku: ").append(toIndentedString(sku)).append("\n");
    sb.append("    taxItems: ").append(toIndentedString(taxItems)).append("\n");
    sb.append("    unbilledReceivablesAccountingCode: ").append(toIndentedString(unbilledReceivablesAccountingCode)).append("\n");
    sb.append("    unitPrice: ").append(toIndentedString(unitPrice)).append("\n");
    sb.append("    additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
    sb.append("}");
    return sb.toString();
  }

  /**
   * Convert the given object to string with each line indented by 4 spaces
   * (except the first line).
   */
  private String toIndentedString(Object o) {
    if (o == null) {
      return "null";
    }
    return o.toString().replace("\n", "\n    ");
  }


  public static HashSet openapiFields;
  public static HashSet openapiRequiredFields;

  static {
    // a set of all properties/fields (JSON key names)
    openapiFields = new HashSet();
    openapiFields.add("IntegrationId__NS");
    openapiFields.add("IntegrationStatus__NS");
    openapiFields.add("SyncDate__NS");
    openapiFields.add("accountingCode");
    openapiFields.add("accountsReceivableAccountingCode");
    openapiFields.add("adjustmentLiabilityAccountingCode");
    openapiFields.add("adjustmentRevenueAccountingCode");
    openapiFields.add("amount");
    openapiFields.add("bookingReference");
    openapiFields.add("chargeDate");
    openapiFields.add("chargeName");
    openapiFields.add("contractAssetAccountingCode");
    openapiFields.add("contractLiabilityAccountingCode");
    openapiFields.add("contractRecognizedRevenueAccountingCode");
    openapiFields.add("deferredRevenueAccountingCode");
    openapiFields.add("description");
    openapiFields.add("itemType");
    openapiFields.add("productRatePlanChargeId");
    openapiFields.add("purchaseOrderNumber");
    openapiFields.add("recognizedRevenueAccountingCode");
    openapiFields.add("revRecCode");
    openapiFields.add("revRecTriggerCondition");
    openapiFields.add("revenueRecognitionRuleName");
    openapiFields.add("sku");
    openapiFields.add("taxItems");
    openapiFields.add("unbilledReceivablesAccountingCode");
    openapiFields.add("unitPrice");

    // a set of required properties/fields (JSON key names)
    openapiRequiredFields = new HashSet();
    openapiRequiredFields.add("amount");
  }

  /**
   * Validates the JSON Element and throws an exception if issues found
   *
   * @param jsonElement JSON Element
   * @throws IOException if the JSON Element is invalid with respect to CreateDiscountItem
   */
  public static void validateJsonElement(JsonElement jsonElement) throws IOException {
      if (jsonElement == null) {
        if (!CreateDiscountItem.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
          throw new IllegalArgumentException(String.format("The required field(s) %s in CreateDiscountItem is not found in the empty JSON string", CreateDiscountItem.openapiRequiredFields.toString()));
        }
      }

      // check to make sure all required properties/fields are present in the JSON string
      for (String requiredField : CreateDiscountItem.openapiRequiredFields) {
        if (jsonElement.getAsJsonObject().get(requiredField) == null) {
          throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString()));
        }
      }
        JsonObject jsonObj = jsonElement.getAsJsonObject();
      if ((jsonObj.get("IntegrationId__NS") != null && !jsonObj.get("IntegrationId__NS").isJsonNull()) && !jsonObj.get("IntegrationId__NS").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `IntegrationId__NS` to be a primitive type in the JSON string but got `%s`", jsonObj.get("IntegrationId__NS").toString()));
      }
      if ((jsonObj.get("IntegrationStatus__NS") != null && !jsonObj.get("IntegrationStatus__NS").isJsonNull()) && !jsonObj.get("IntegrationStatus__NS").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `IntegrationStatus__NS` to be a primitive type in the JSON string but got `%s`", jsonObj.get("IntegrationStatus__NS").toString()));
      }
      if ((jsonObj.get("SyncDate__NS") != null && !jsonObj.get("SyncDate__NS").isJsonNull()) && !jsonObj.get("SyncDate__NS").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `SyncDate__NS` to be a primitive type in the JSON string but got `%s`", jsonObj.get("SyncDate__NS").toString()));
      }
      if ((jsonObj.get("accountingCode") != null && !jsonObj.get("accountingCode").isJsonNull()) && !jsonObj.get("accountingCode").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `accountingCode` to be a primitive type in the JSON string but got `%s`", jsonObj.get("accountingCode").toString()));
      }
      if ((jsonObj.get("accountsReceivableAccountingCode") != null && !jsonObj.get("accountsReceivableAccountingCode").isJsonNull()) && !jsonObj.get("accountsReceivableAccountingCode").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `accountsReceivableAccountingCode` to be a primitive type in the JSON string but got `%s`", jsonObj.get("accountsReceivableAccountingCode").toString()));
      }
      if ((jsonObj.get("adjustmentLiabilityAccountingCode") != null && !jsonObj.get("adjustmentLiabilityAccountingCode").isJsonNull()) && !jsonObj.get("adjustmentLiabilityAccountingCode").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `adjustmentLiabilityAccountingCode` to be a primitive type in the JSON string but got `%s`", jsonObj.get("adjustmentLiabilityAccountingCode").toString()));
      }
      if ((jsonObj.get("adjustmentRevenueAccountingCode") != null && !jsonObj.get("adjustmentRevenueAccountingCode").isJsonNull()) && !jsonObj.get("adjustmentRevenueAccountingCode").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `adjustmentRevenueAccountingCode` to be a primitive type in the JSON string but got `%s`", jsonObj.get("adjustmentRevenueAccountingCode").toString()));
      }
      if ((jsonObj.get("bookingReference") != null && !jsonObj.get("bookingReference").isJsonNull()) && !jsonObj.get("bookingReference").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `bookingReference` to be a primitive type in the JSON string but got `%s`", jsonObj.get("bookingReference").toString()));
      }
      if ((jsonObj.get("chargeDate") != null && !jsonObj.get("chargeDate").isJsonNull()) && !jsonObj.get("chargeDate").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `chargeDate` to be a primitive type in the JSON string but got `%s`", jsonObj.get("chargeDate").toString()));
      }
      if ((jsonObj.get("chargeName") != null && !jsonObj.get("chargeName").isJsonNull()) && !jsonObj.get("chargeName").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `chargeName` to be a primitive type in the JSON string but got `%s`", jsonObj.get("chargeName").toString()));
      }
      if ((jsonObj.get("contractAssetAccountingCode") != null && !jsonObj.get("contractAssetAccountingCode").isJsonNull()) && !jsonObj.get("contractAssetAccountingCode").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `contractAssetAccountingCode` to be a primitive type in the JSON string but got `%s`", jsonObj.get("contractAssetAccountingCode").toString()));
      }
      if ((jsonObj.get("contractLiabilityAccountingCode") != null && !jsonObj.get("contractLiabilityAccountingCode").isJsonNull()) && !jsonObj.get("contractLiabilityAccountingCode").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `contractLiabilityAccountingCode` to be a primitive type in the JSON string but got `%s`", jsonObj.get("contractLiabilityAccountingCode").toString()));
      }
      if ((jsonObj.get("contractRecognizedRevenueAccountingCode") != null && !jsonObj.get("contractRecognizedRevenueAccountingCode").isJsonNull()) && !jsonObj.get("contractRecognizedRevenueAccountingCode").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `contractRecognizedRevenueAccountingCode` to be a primitive type in the JSON string but got `%s`", jsonObj.get("contractRecognizedRevenueAccountingCode").toString()));
      }
      if ((jsonObj.get("deferredRevenueAccountingCode") != null && !jsonObj.get("deferredRevenueAccountingCode").isJsonNull()) && !jsonObj.get("deferredRevenueAccountingCode").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `deferredRevenueAccountingCode` to be a primitive type in the JSON string but got `%s`", jsonObj.get("deferredRevenueAccountingCode").toString()));
      }
      if ((jsonObj.get("description") != null && !jsonObj.get("description").isJsonNull()) && !jsonObj.get("description").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString()));
      }
      if ((jsonObj.get("itemType") != null && !jsonObj.get("itemType").isJsonNull()) && !jsonObj.get("itemType").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `itemType` to be a primitive type in the JSON string but got `%s`", jsonObj.get("itemType").toString()));
      }
      if ((jsonObj.get("productRatePlanChargeId") != null && !jsonObj.get("productRatePlanChargeId").isJsonNull()) && !jsonObj.get("productRatePlanChargeId").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `productRatePlanChargeId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("productRatePlanChargeId").toString()));
      }
      if ((jsonObj.get("purchaseOrderNumber") != null && !jsonObj.get("purchaseOrderNumber").isJsonNull()) && !jsonObj.get("purchaseOrderNumber").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `purchaseOrderNumber` to be a primitive type in the JSON string but got `%s`", jsonObj.get("purchaseOrderNumber").toString()));
      }
      if ((jsonObj.get("recognizedRevenueAccountingCode") != null && !jsonObj.get("recognizedRevenueAccountingCode").isJsonNull()) && !jsonObj.get("recognizedRevenueAccountingCode").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `recognizedRevenueAccountingCode` to be a primitive type in the JSON string but got `%s`", jsonObj.get("recognizedRevenueAccountingCode").toString()));
      }
      if ((jsonObj.get("revRecCode") != null && !jsonObj.get("revRecCode").isJsonNull()) && !jsonObj.get("revRecCode").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `revRecCode` to be a primitive type in the JSON string but got `%s`", jsonObj.get("revRecCode").toString()));
      }
      if ((jsonObj.get("revRecTriggerCondition") != null && !jsonObj.get("revRecTriggerCondition").isJsonNull()) && !jsonObj.get("revRecTriggerCondition").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `revRecTriggerCondition` to be a primitive type in the JSON string but got `%s`", jsonObj.get("revRecTriggerCondition").toString()));
      }
      // validate the optional field `revRecTriggerCondition`
      if (jsonObj.get("revRecTriggerCondition") != null && !jsonObj.get("revRecTriggerCondition").isJsonNull()) {
        RevRecTrigger.validateJsonElement(jsonObj.get("revRecTriggerCondition"));
      }
      if ((jsonObj.get("revenueRecognitionRuleName") != null && !jsonObj.get("revenueRecognitionRuleName").isJsonNull()) && !jsonObj.get("revenueRecognitionRuleName").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `revenueRecognitionRuleName` to be a primitive type in the JSON string but got `%s`", jsonObj.get("revenueRecognitionRuleName").toString()));
      }
      if ((jsonObj.get("sku") != null && !jsonObj.get("sku").isJsonNull()) && !jsonObj.get("sku").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `sku` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sku").toString()));
      }
      // ensure the optional json data is an array if present
      if (jsonObj.get("taxItems") != null && !jsonObj.get("taxItems").isJsonNull() && !jsonObj.get("taxItems").isJsonArray()) {
        throw new IllegalArgumentException(String.format("Expected the field `taxItems` to be an array in the JSON string but got `%s`", jsonObj.get("taxItems").toString()));
      }
      if ((jsonObj.get("unbilledReceivablesAccountingCode") != null && !jsonObj.get("unbilledReceivablesAccountingCode").isJsonNull()) && !jsonObj.get("unbilledReceivablesAccountingCode").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `unbilledReceivablesAccountingCode` to be a primitive type in the JSON string but got `%s`", jsonObj.get("unbilledReceivablesAccountingCode").toString()));
      }
  }

  public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
    @SuppressWarnings("unchecked")
    @Override
    public  TypeAdapter create(Gson gson, TypeToken type) {
       if (!CreateDiscountItem.class.isAssignableFrom(type.getRawType())) {
         return null; // this class only serializes 'CreateDiscountItem' and its subtypes
       }
       final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
       final TypeAdapter thisAdapter
                        = gson.getDelegateAdapter(this, TypeToken.get(CreateDiscountItem.class));

       return (TypeAdapter) new TypeAdapter() {
           @Override
           public void write(JsonWriter out, CreateDiscountItem value) throws IOException {
             JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
             obj.remove("additionalProperties");

             // support null values
             out.beginObject();
             Iterator iterator = obj.entrySet().iterator();
             while(iterator.hasNext()) {
                 Map.Entry e = (Map.Entry) iterator.next();
                 out.name((String)e.getKey());
                 elementAdapter.write(out, e.getValue());
             }

             // end

             // serialize additional properties
             if (value.getAdditionalProperties() != null) {
               // support null values
               boolean oldSerializeNulls = out.getSerializeNulls();
               out.setSerializeNulls(true); //force serialize
               // end
               for (Map.Entry entry : value.getAdditionalProperties().entrySet()) {
                 if (entry.getValue() instanceof String)
                   obj.addProperty(entry.getKey(), (String) entry.getValue());
                 else if (entry.getValue() instanceof Number)
                   obj.addProperty(entry.getKey(), (Number) entry.getValue());
                 else if (entry.getValue() instanceof Boolean)
                   obj.addProperty(entry.getKey(), (Boolean) entry.getValue());
                 else if (entry.getValue() instanceof Character)
                   obj.addProperty(entry.getKey(), (Character) entry.getValue());
                 else if (entry.getValue() == null)
                    obj.add(entry.getKey(), null);
                 else {
                   JsonElement jsonElement = gson.toJsonTree(entry.getValue());
                   if (jsonElement.isJsonArray()) {
                     obj.add(entry.getKey(), jsonElement.getAsJsonArray());
                   } else {
                     obj.add(entry.getKey(), jsonElement.getAsJsonObject());
                   }
                 }
                 out.name((String)entry.getKey());
                 elementAdapter.write(out, obj.get(entry.getKey()));
               }
               out.setSerializeNulls(oldSerializeNulls); //restore
             }
             out.endObject();

           }

           @Override
           public CreateDiscountItem read(JsonReader in) throws IOException {
             JsonElement jsonElement = elementAdapter.read(in);
             validateJsonElement(jsonElement);
             JsonObject jsonObj = jsonElement.getAsJsonObject();
             // store additional fields in the deserialized instance
             CreateDiscountItem instance = thisAdapter.fromJsonTree(jsonObj);
             for (Map.Entry entry : jsonObj.entrySet()) {
               if (!openapiFields.contains(entry.getKey())) {
                 if (entry.getValue().isJsonPrimitive()) { // primitive type
                   if (entry.getValue().getAsJsonPrimitive().isString())
                     instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString());
                   else if (entry.getValue().getAsJsonPrimitive().isNumber())
                     instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber());
                   else if (entry.getValue().getAsJsonPrimitive().isBoolean())
                     instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean());
                   else
                     throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString()));
                 } else if (entry.getValue().isJsonArray()) {
                     instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class));
                 } else { // JSON object
                     instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class));
                 }
               }
             }
             return instance;
           }

       }.nullSafe();
    }
  }

  /**
   * Create an instance of CreateDiscountItem given an JSON string
   *
   * @param jsonString JSON string
   * @return An instance of CreateDiscountItem
   * @throws IOException if the JSON string is invalid with respect to CreateDiscountItem
   */
  public static CreateDiscountItem fromJson(String jsonString) throws IOException {
    return JSON.getGson().fromJson(jsonString, CreateDiscountItem.class);
  }

  /**
   * Convert an instance of CreateDiscountItem to an JSON string
   *
   * @return JSON string
   */
  public String toJson() {
    return JSON.getGson().toJson(this);
  }
}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy