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

com.zuora.model.OrderActionCreateSubscription 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.CreateOrderSubscriptionOwnerAccount;
import com.zuora.model.OrderActionCreateSubscriptionTerms;
import com.zuora.model.RatePlanOverride;
import com.zuora.model.SubscribeToProduct;
import java.io.IOException;
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;

/**
 * Information about an order action of type `CreateSubscription`. 
 */
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.6.0")
public class OrderActionCreateSubscription {
  public static final String SERIALIZED_NAME_BILL_TO_CONTACT_ID = "billToContactId";
  @SerializedName(SERIALIZED_NAME_BILL_TO_CONTACT_ID)
  private String billToContactId;

  public static final String SERIALIZED_NAME_INVOICE_GROUP_NUMBER = "invoiceGroupNumber";
  @SerializedName(SERIALIZED_NAME_INVOICE_GROUP_NUMBER)
  private String invoiceGroupNumber;

  public static final String SERIALIZED_NAME_INVOICE_SEPARATELY = "invoiceSeparately";
  @SerializedName(SERIALIZED_NAME_INVOICE_SEPARATELY)
  private Boolean invoiceSeparately;

  public static final String SERIALIZED_NAME_INVOICE_TEMPLATE_ID = "invoiceTemplateId";
  @SerializedName(SERIALIZED_NAME_INVOICE_TEMPLATE_ID)
  private String invoiceTemplateId;

  public static final String SERIALIZED_NAME_NEW_SUBSCRIPTION_OWNER_ACCOUNT = "newSubscriptionOwnerAccount";
  @SerializedName(SERIALIZED_NAME_NEW_SUBSCRIPTION_OWNER_ACCOUNT)
  private CreateOrderSubscriptionOwnerAccount newSubscriptionOwnerAccount;

  public static final String SERIALIZED_NAME_NOTES = "notes";
  @SerializedName(SERIALIZED_NAME_NOTES)
  private String notes;

  public static final String SERIALIZED_NAME_PAYMENT_TERM = "paymentTerm";
  @SerializedName(SERIALIZED_NAME_PAYMENT_TERM)
  private String paymentTerm;

  public static final String SERIALIZED_NAME_SEQUENCE_SET_ID = "sequenceSetId";
  @SerializedName(SERIALIZED_NAME_SEQUENCE_SET_ID)
  private String sequenceSetId;

  public static final String SERIALIZED_NAME_SOLD_TO_CONTACT_ID = "soldToContactId";
  @SerializedName(SERIALIZED_NAME_SOLD_TO_CONTACT_ID)
  private String soldToContactId;

  public static final String SERIALIZED_NAME_SHIP_TO_CONTACT_ID = "shipToContactId";
  @SerializedName(SERIALIZED_NAME_SHIP_TO_CONTACT_ID)
  private String shipToContactId;

  public static final String SERIALIZED_NAME_SUBSCRIBE_TO_PRODUCTS = "subscribeToProducts";
  @SerializedName(SERIALIZED_NAME_SUBSCRIBE_TO_PRODUCTS)
  private List subscribeToProducts;

  public static final String SERIALIZED_NAME_SUBSCRIBE_TO_RATE_PLANS = "subscribeToRatePlans";
  @SerializedName(SERIALIZED_NAME_SUBSCRIBE_TO_RATE_PLANS)
  private List subscribeToRatePlans;

  public static final String SERIALIZED_NAME_SUBSCRIPTION_NUMBER = "subscriptionNumber";
  @SerializedName(SERIALIZED_NAME_SUBSCRIPTION_NUMBER)
  private String subscriptionNumber;

  public static final String SERIALIZED_NAME_SUBSCRIPTION_OWNER_ACCOUNT_NUMBER = "subscriptionOwnerAccountNumber";
  @SerializedName(SERIALIZED_NAME_SUBSCRIPTION_OWNER_ACCOUNT_NUMBER)
  private String subscriptionOwnerAccountNumber;

  public static final String SERIALIZED_NAME_TERMS = "terms";
  @SerializedName(SERIALIZED_NAME_TERMS)
  private OrderActionCreateSubscriptionTerms terms;

  public OrderActionCreateSubscription() {
  }

  public OrderActionCreateSubscription billToContactId(String billToContactId) {
    this.billToContactId = billToContactId;
    return this;
  }

  /**
   * The ID of the bill-to contact associated with the subscription.  **Note**:    - If you have the <a href=\"https://knowledgecenter.zuora.com/Zuora_Billing/Bill_your_customers/Bill_customers_at_subscription_level/Flexible_Billing_Attributes\" target=\"_blank\">Flexible Billing Attributes</a> feature disabled, this field is unavailable in the request body and the value of this field is `null` in the response body.    - If you have the Flexible Billing Attributes feature enabled, and you do not specify this field in the request or you select **Default Contact from Account** for this field during subscription creation, the value of this field is automatically set to `null` in the response body. 
   * @return billToContactId
   */
  @javax.annotation.Nullable
  public String getBillToContactId() {
    return billToContactId;
  }

  public void setBillToContactId(String billToContactId) {
    this.billToContactId = billToContactId;
  }


  public OrderActionCreateSubscription invoiceGroupNumber(String invoiceGroupNumber) {
    this.invoiceGroupNumber = invoiceGroupNumber;
    return this;
  }

  /**
   * The number of invoice group associated with the subscription.  **Note**: This field is available only if you have the <a href=\"https://knowledgecenter.zuora.com/Zuora_Billing/Bill_your_customers/Bill_customers_at_subscription_level/Flexible_Billing_Attributes\" target=\"_blank\">Flexible Billing Attributes</a> feature enabled. 
   * @return invoiceGroupNumber
   */
  @javax.annotation.Nullable
  public String getInvoiceGroupNumber() {
    return invoiceGroupNumber;
  }

  public void setInvoiceGroupNumber(String invoiceGroupNumber) {
    this.invoiceGroupNumber = invoiceGroupNumber;
  }


  public OrderActionCreateSubscription invoiceSeparately(Boolean invoiceSeparately) {
    this.invoiceSeparately = invoiceSeparately;
    return this;
  }

  /**
   * Specifies whether the subscription appears on a separate invoice when Zuora generates invoices. 
   * @return invoiceSeparately
   */
  @javax.annotation.Nullable
  public Boolean getInvoiceSeparately() {
    return invoiceSeparately;
  }

  public void setInvoiceSeparately(Boolean invoiceSeparately) {
    this.invoiceSeparately = invoiceSeparately;
  }


  public OrderActionCreateSubscription invoiceTemplateId(String invoiceTemplateId) {
    this.invoiceTemplateId = invoiceTemplateId;
    return this;
  }

  /**
   * The ID of the invoice template associated with the subscription.  **Note**:    - If you have the <a href=\"https://knowledgecenter.zuora.com/Zuora_Billing/Bill_your_customers/Bill_customers_at_subscription_level/Flexible_Billing_Attributes\" target=\"_blank\">Flexible Billing Attributes</a> feature disabled, this field is unavailable in the request body and the value of this field is `null` in the response body.    - If you have the Flexible Billing Attributes feature enabled, and you do not specify this field in the request or you select **Default Template from Account** for this field during subscription creation, the value of this field is automatically set to `null` in the response body. 
   * @return invoiceTemplateId
   */
  @javax.annotation.Nullable
  public String getInvoiceTemplateId() {
    return invoiceTemplateId;
  }

  public void setInvoiceTemplateId(String invoiceTemplateId) {
    this.invoiceTemplateId = invoiceTemplateId;
  }


  public OrderActionCreateSubscription newSubscriptionOwnerAccount(CreateOrderSubscriptionOwnerAccount newSubscriptionOwnerAccount) {
    this.newSubscriptionOwnerAccount = newSubscriptionOwnerAccount;
    return this;
  }

  /**
   * Get newSubscriptionOwnerAccount
   * @return newSubscriptionOwnerAccount
   */
  @javax.annotation.Nullable
  public CreateOrderSubscriptionOwnerAccount getNewSubscriptionOwnerAccount() {
    return newSubscriptionOwnerAccount;
  }

  public void setNewSubscriptionOwnerAccount(CreateOrderSubscriptionOwnerAccount newSubscriptionOwnerAccount) {
    this.newSubscriptionOwnerAccount = newSubscriptionOwnerAccount;
  }


  public OrderActionCreateSubscription notes(String notes) {
    this.notes = notes;
    return this;
  }

  /**
   * Notes about the subscription. These notes are only visible to Zuora users. 
   * @return notes
   */
  @javax.annotation.Nullable
  public String getNotes() {
    return notes;
  }

  public void setNotes(String notes) {
    this.notes = notes;
  }


  public OrderActionCreateSubscription paymentTerm(String paymentTerm) {
    this.paymentTerm = paymentTerm;
    return this;
  }

  /**
   * The name of the payment term associated with the subscription. For example, `Net 30`. The payment term determines the due dates of invoices.  **Note**:    - If you have the <a href=\"https://knowledgecenter.zuora.com/Zuora_Billing/Bill_your_customers/Bill_customers_at_subscription_level/Flexible_Billing_Attributes\" target=\"_blank\">Flexible Billing Attributes</a> feature disabled, this field is unavailable in the request body and the value of this field is `null` in the response body.    - If you have the Flexible Billing Attributes feature enabled, and you do not specify this field in the request or you select **Default Term from Account** for this field during subscription creation, the value of this field is automatically set to `null` in the response body. 
   * @return paymentTerm
   */
  @javax.annotation.Nullable
  public String getPaymentTerm() {
    return paymentTerm;
  }

  public void setPaymentTerm(String paymentTerm) {
    this.paymentTerm = paymentTerm;
  }


  public OrderActionCreateSubscription sequenceSetId(String sequenceSetId) {
    this.sequenceSetId = sequenceSetId;
    return this;
  }

  /**
   * The ID of the sequence set associated with the subscription.  **Note**:    - If you have the <a href=\"https://knowledgecenter.zuora.com/Zuora_Billing/Bill_your_customers/Bill_customers_at_subscription_level/Flexible_Billing_Attributes\" target=\"_blank\">Flexible Billing Attributes</a> feature disabled, this field is unavailable in the request body and the value of this field is `null` in the response body.    - If you have the Flexible Billing Attributes feature enabled, and you do not specify this field in the request or you select **Default Set from Account** for this field during subscription creation, the value of this field is automatically set to `null` in the response body. 
   * @return sequenceSetId
   */
  @javax.annotation.Nullable
  public String getSequenceSetId() {
    return sequenceSetId;
  }

  public void setSequenceSetId(String sequenceSetId) {
    this.sequenceSetId = sequenceSetId;
  }


  public OrderActionCreateSubscription soldToContactId(String soldToContactId) {
    this.soldToContactId = soldToContactId;
    return this;
  }

  /**
   * The ID of the sold-to contact associated with the subscription.  **Note**:    - If you have the <a href=\"https://knowledgecenter.zuora.com/Zuora_Billing/Bill_your_customers/Bill_customers_at_subscription_level/Flexible_Billing_Attributes\" target=\"_blank\">Flexible Billing Attributes</a> feature disabled, this field is unavailable in the request body and the value of this field is `null` in the response body.    - If you have the Flexible Billing Attributes feature enabled, and you do not specify this field in the request or you select **Default Contact from Account** for this field during subscription creation, the value of this field is automatically set to `null` in the response body. 
   * @return soldToContactId
   */
  @javax.annotation.Nullable
  public String getSoldToContactId() {
    return soldToContactId;
  }

  public void setSoldToContactId(String soldToContactId) {
    this.soldToContactId = soldToContactId;
  }


  public OrderActionCreateSubscription shipToContactId(String shipToContactId) {
    this.shipToContactId = shipToContactId;
    return this;
  }

  /**
   * The ID of the ship-to contact associated with the subscription.
   * @return shipToContactId
   */
  @javax.annotation.Nullable
  public String getShipToContactId() {
    return shipToContactId;
  }

  public void setShipToContactId(String shipToContactId) {
    this.shipToContactId = shipToContactId;
  }


  public OrderActionCreateSubscription subscribeToProducts(List subscribeToProducts) {
    this.subscribeToProducts = subscribeToProducts;
    return this;
  }

  public OrderActionCreateSubscription addSubscribeToProductsItem(SubscribeToProduct subscribeToProductsItem) {
    if (this.subscribeToProducts == null) {
      this.subscribeToProducts = new ArrayList<>();
    }
    this.subscribeToProducts.add(subscribeToProductsItem);
    return this;
  }

  /**
   * For a rate plan, the following fields are available:   - `chargeOverrides`   - `clearingExistingFeatures`   - `customFields`   - `externallyManagedPlanId`   - `newRatePlanId`   - `productRatePlanId`   - `subscriptionProductFeatures`   - `uniqueToken`    
   * @return subscribeToProducts
   */
  @javax.annotation.Nullable
  public List getSubscribeToProducts() {
    return subscribeToProducts;
  }

  public void setSubscribeToProducts(List subscribeToProducts) {
    this.subscribeToProducts = subscribeToProducts;
  }


  public OrderActionCreateSubscription subscribeToRatePlans(List subscribeToRatePlans) {
    this.subscribeToRatePlans = subscribeToRatePlans;
    return this;
  }

  public OrderActionCreateSubscription addSubscribeToRatePlansItem(RatePlanOverride subscribeToRatePlansItem) {
    if (this.subscribeToRatePlans == null) {
      this.subscribeToRatePlans = new ArrayList<>();
    }
    this.subscribeToRatePlans.add(subscribeToRatePlansItem);
    return this;
  }

  /**
   * List of rate plans associated with the subscription.  **Note**: The `subscribeToRatePlans` field has been deprecated, this field is replaced by the `subscribeToProducts` field that supports Rate Plans. In a new order request, you can use either `subscribeToRatePlans` or `subscribeToProducts`, not both. 
   * @return subscribeToRatePlans
   */
  @javax.annotation.Nullable
  public List getSubscribeToRatePlans() {
    return subscribeToRatePlans;
  }

  public void setSubscribeToRatePlans(List subscribeToRatePlans) {
    this.subscribeToRatePlans = subscribeToRatePlans;
  }


  public OrderActionCreateSubscription subscriptionNumber(String subscriptionNumber) {
    this.subscriptionNumber = subscriptionNumber;
    return this;
  }

  /**
   * Subscription number of the subscription. For example, A-S00000001.  If you do not set this field, Zuora will generate the subscription number. 
   * @return subscriptionNumber
   */
  @javax.annotation.Nullable
  public String getSubscriptionNumber() {
    return subscriptionNumber;
  }

  public void setSubscriptionNumber(String subscriptionNumber) {
    this.subscriptionNumber = subscriptionNumber;
  }


  public OrderActionCreateSubscription subscriptionOwnerAccountNumber(String subscriptionOwnerAccountNumber) {
    this.subscriptionOwnerAccountNumber = subscriptionOwnerAccountNumber;
    return this;
  }

  /**
   * Account number of an existing account that will own the subscription. For example, A00000001.  If you do not set this field or the `newSubscriptionOwnerAccount` field, the account that owns the order will also own the subscription. Zuora will return an error if you set this field and the `newSubscriptionOwnerAccount` field. 
   * @return subscriptionOwnerAccountNumber
   */
  @javax.annotation.Nullable
  public String getSubscriptionOwnerAccountNumber() {
    return subscriptionOwnerAccountNumber;
  }

  public void setSubscriptionOwnerAccountNumber(String subscriptionOwnerAccountNumber) {
    this.subscriptionOwnerAccountNumber = subscriptionOwnerAccountNumber;
  }


  public OrderActionCreateSubscription terms(OrderActionCreateSubscriptionTerms terms) {
    this.terms = terms;
    return this;
  }

  /**
   * Get terms
   * @return terms
   */
  @javax.annotation.Nullable
  public OrderActionCreateSubscriptionTerms getTerms() {
    return terms;
  }

  public void setTerms(OrderActionCreateSubscriptionTerms terms) {
    this.terms = terms;
  }

  /**
   * 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 OrderActionCreateSubscription instance itself
   */
  public OrderActionCreateSubscription 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;
    }
    OrderActionCreateSubscription orderActionCreateSubscription = (OrderActionCreateSubscription) o;
    return Objects.equals(this.billToContactId, orderActionCreateSubscription.billToContactId) &&
        Objects.equals(this.invoiceGroupNumber, orderActionCreateSubscription.invoiceGroupNumber) &&
        Objects.equals(this.invoiceSeparately, orderActionCreateSubscription.invoiceSeparately) &&
        Objects.equals(this.invoiceTemplateId, orderActionCreateSubscription.invoiceTemplateId) &&
        Objects.equals(this.newSubscriptionOwnerAccount, orderActionCreateSubscription.newSubscriptionOwnerAccount) &&
        Objects.equals(this.notes, orderActionCreateSubscription.notes) &&
        Objects.equals(this.paymentTerm, orderActionCreateSubscription.paymentTerm) &&
        Objects.equals(this.sequenceSetId, orderActionCreateSubscription.sequenceSetId) &&
        Objects.equals(this.soldToContactId, orderActionCreateSubscription.soldToContactId) &&
        Objects.equals(this.shipToContactId, orderActionCreateSubscription.shipToContactId) &&
        Objects.equals(this.subscribeToProducts, orderActionCreateSubscription.subscribeToProducts) &&
        Objects.equals(this.subscribeToRatePlans, orderActionCreateSubscription.subscribeToRatePlans) &&
        Objects.equals(this.subscriptionNumber, orderActionCreateSubscription.subscriptionNumber) &&
        Objects.equals(this.subscriptionOwnerAccountNumber, orderActionCreateSubscription.subscriptionOwnerAccountNumber) &&
        Objects.equals(this.terms, orderActionCreateSubscription.terms)&&
        Objects.equals(this.additionalProperties, orderActionCreateSubscription.additionalProperties);
  }

  @Override
  public int hashCode() {
    return Objects.hash(billToContactId, invoiceGroupNumber, invoiceSeparately, invoiceTemplateId, newSubscriptionOwnerAccount, notes, paymentTerm, sequenceSetId, soldToContactId, shipToContactId, subscribeToProducts, subscribeToRatePlans, subscriptionNumber, subscriptionOwnerAccountNumber, terms, additionalProperties);
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("class OrderActionCreateSubscription {\n");
    sb.append("    billToContactId: ").append(toIndentedString(billToContactId)).append("\n");
    sb.append("    invoiceGroupNumber: ").append(toIndentedString(invoiceGroupNumber)).append("\n");
    sb.append("    invoiceSeparately: ").append(toIndentedString(invoiceSeparately)).append("\n");
    sb.append("    invoiceTemplateId: ").append(toIndentedString(invoiceTemplateId)).append("\n");
    sb.append("    newSubscriptionOwnerAccount: ").append(toIndentedString(newSubscriptionOwnerAccount)).append("\n");
    sb.append("    notes: ").append(toIndentedString(notes)).append("\n");
    sb.append("    paymentTerm: ").append(toIndentedString(paymentTerm)).append("\n");
    sb.append("    sequenceSetId: ").append(toIndentedString(sequenceSetId)).append("\n");
    sb.append("    soldToContactId: ").append(toIndentedString(soldToContactId)).append("\n");
    sb.append("    shipToContactId: ").append(toIndentedString(shipToContactId)).append("\n");
    sb.append("    subscribeToProducts: ").append(toIndentedString(subscribeToProducts)).append("\n");
    sb.append("    subscribeToRatePlans: ").append(toIndentedString(subscribeToRatePlans)).append("\n");
    sb.append("    subscriptionNumber: ").append(toIndentedString(subscriptionNumber)).append("\n");
    sb.append("    subscriptionOwnerAccountNumber: ").append(toIndentedString(subscriptionOwnerAccountNumber)).append("\n");
    sb.append("    terms: ").append(toIndentedString(terms)).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("billToContactId");
    openapiFields.add("invoiceGroupNumber");
    openapiFields.add("invoiceSeparately");
    openapiFields.add("invoiceTemplateId");
    openapiFields.add("newSubscriptionOwnerAccount");
    openapiFields.add("notes");
    openapiFields.add("paymentTerm");
    openapiFields.add("sequenceSetId");
    openapiFields.add("soldToContactId");
    openapiFields.add("shipToContactId");
    openapiFields.add("subscribeToProducts");
    openapiFields.add("subscribeToRatePlans");
    openapiFields.add("subscriptionNumber");
    openapiFields.add("subscriptionOwnerAccountNumber");
    openapiFields.add("terms");

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

  /**
   * 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 OrderActionCreateSubscription
   */
  public static void validateJsonElement(JsonElement jsonElement) throws IOException {
      if (jsonElement == null) {
        if (!OrderActionCreateSubscription.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
          throw new IllegalArgumentException(String.format("The required field(s) %s in OrderActionCreateSubscription is not found in the empty JSON string", OrderActionCreateSubscription.openapiRequiredFields.toString()));
        }
      }
        JsonObject jsonObj = jsonElement.getAsJsonObject();
      if ((jsonObj.get("billToContactId") != null && !jsonObj.get("billToContactId").isJsonNull()) && !jsonObj.get("billToContactId").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `billToContactId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("billToContactId").toString()));
      }
      if ((jsonObj.get("invoiceGroupNumber") != null && !jsonObj.get("invoiceGroupNumber").isJsonNull()) && !jsonObj.get("invoiceGroupNumber").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `invoiceGroupNumber` to be a primitive type in the JSON string but got `%s`", jsonObj.get("invoiceGroupNumber").toString()));
      }
      if ((jsonObj.get("invoiceTemplateId") != null && !jsonObj.get("invoiceTemplateId").isJsonNull()) && !jsonObj.get("invoiceTemplateId").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `invoiceTemplateId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("invoiceTemplateId").toString()));
      }
      // validate the optional field `newSubscriptionOwnerAccount`
      if (jsonObj.get("newSubscriptionOwnerAccount") != null && !jsonObj.get("newSubscriptionOwnerAccount").isJsonNull()) {
        CreateOrderSubscriptionOwnerAccount.validateJsonElement(jsonObj.get("newSubscriptionOwnerAccount"));
      }
      if ((jsonObj.get("notes") != null && !jsonObj.get("notes").isJsonNull()) && !jsonObj.get("notes").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `notes` to be a primitive type in the JSON string but got `%s`", jsonObj.get("notes").toString()));
      }
      if ((jsonObj.get("paymentTerm") != null && !jsonObj.get("paymentTerm").isJsonNull()) && !jsonObj.get("paymentTerm").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `paymentTerm` to be a primitive type in the JSON string but got `%s`", jsonObj.get("paymentTerm").toString()));
      }
      if ((jsonObj.get("sequenceSetId") != null && !jsonObj.get("sequenceSetId").isJsonNull()) && !jsonObj.get("sequenceSetId").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `sequenceSetId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sequenceSetId").toString()));
      }
      if ((jsonObj.get("soldToContactId") != null && !jsonObj.get("soldToContactId").isJsonNull()) && !jsonObj.get("soldToContactId").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `soldToContactId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("soldToContactId").toString()));
      }
      if ((jsonObj.get("shipToContactId") != null && !jsonObj.get("shipToContactId").isJsonNull()) && !jsonObj.get("shipToContactId").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `shipToContactId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("shipToContactId").toString()));
      }
      if (jsonObj.get("subscribeToProducts") != null && !jsonObj.get("subscribeToProducts").isJsonNull()) {
        JsonArray jsonArraysubscribeToProducts = jsonObj.getAsJsonArray("subscribeToProducts");
        if (jsonArraysubscribeToProducts != null) {
          // ensure the json data is an array
          if (!jsonObj.get("subscribeToProducts").isJsonArray()) {
            throw new IllegalArgumentException(String.format("Expected the field `subscribeToProducts` to be an array in the JSON string but got `%s`", jsonObj.get("subscribeToProducts").toString()));
          }

          // validate the optional field `subscribeToProducts` (array)
          for (int i = 0; i < jsonArraysubscribeToProducts.size(); i++) {
            SubscribeToProduct.validateJsonElement(jsonArraysubscribeToProducts.get(i));
          };
        }
      }
      if (jsonObj.get("subscribeToRatePlans") != null && !jsonObj.get("subscribeToRatePlans").isJsonNull()) {
        JsonArray jsonArraysubscribeToRatePlans = jsonObj.getAsJsonArray("subscribeToRatePlans");
        if (jsonArraysubscribeToRatePlans != null) {
          // ensure the json data is an array
          if (!jsonObj.get("subscribeToRatePlans").isJsonArray()) {
            throw new IllegalArgumentException(String.format("Expected the field `subscribeToRatePlans` to be an array in the JSON string but got `%s`", jsonObj.get("subscribeToRatePlans").toString()));
          }

          // validate the optional field `subscribeToRatePlans` (array)
          for (int i = 0; i < jsonArraysubscribeToRatePlans.size(); i++) {
            RatePlanOverride.validateJsonElement(jsonArraysubscribeToRatePlans.get(i));
          };
        }
      }
      if ((jsonObj.get("subscriptionNumber") != null && !jsonObj.get("subscriptionNumber").isJsonNull()) && !jsonObj.get("subscriptionNumber").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `subscriptionNumber` to be a primitive type in the JSON string but got `%s`", jsonObj.get("subscriptionNumber").toString()));
      }
      if ((jsonObj.get("subscriptionOwnerAccountNumber") != null && !jsonObj.get("subscriptionOwnerAccountNumber").isJsonNull()) && !jsonObj.get("subscriptionOwnerAccountNumber").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `subscriptionOwnerAccountNumber` to be a primitive type in the JSON string but got `%s`", jsonObj.get("subscriptionOwnerAccountNumber").toString()));
      }
      // validate the optional field `terms`
      if (jsonObj.get("terms") != null && !jsonObj.get("terms").isJsonNull()) {
        OrderActionCreateSubscriptionTerms.validateJsonElement(jsonObj.get("terms"));
      }
  }

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

       return (TypeAdapter) new TypeAdapter() {
           @Override
           public void write(JsonWriter out, OrderActionCreateSubscription 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 OrderActionCreateSubscription read(JsonReader in) throws IOException {
             JsonElement jsonElement = elementAdapter.read(in);
             validateJsonElement(jsonElement);
             JsonObject jsonObj = jsonElement.getAsJsonObject();
             // store additional fields in the deserialized instance
             OrderActionCreateSubscription 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 OrderActionCreateSubscription given an JSON string
   *
   * @param jsonString JSON string
   * @return An instance of OrderActionCreateSubscription
   * @throws IOException if the JSON string is invalid with respect to OrderActionCreateSubscription
   */
  public static OrderActionCreateSubscription fromJson(String jsonString) throws IOException {
    return JSON.getGson().fromJson(jsonString, OrderActionCreateSubscription.class);
  }

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





© 2015 - 2025 Weber Informatics LLC | Privacy Policy