com.zuora.model.PreviewOrderRequest Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of zuora-sdk-java Show documentation
Show all versions of zuora-sdk-java Show documentation
The SDK of JAVA language for Zuora pricing system
/*
* 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.CreateOrderOrderLineItem;
import com.zuora.model.OrderCategory;
import com.zuora.model.PreviewAccountInfo;
import com.zuora.model.PreviewOptions;
import com.zuora.model.PreviewOrderSubscriptions;
import java.io.IOException;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
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;
/**
* PreviewOrderRequest
*/
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.6.0")
public class PreviewOrderRequest {
public static final String SERIALIZED_NAME_CATEGORY = "category";
@SerializedName(SERIALIZED_NAME_CATEGORY)
private OrderCategory category = OrderCategory.NEWSALES;
public static final String SERIALIZED_NAME_CUSTOM_FIELDS = "customFields";
@SerializedName(SERIALIZED_NAME_CUSTOM_FIELDS)
private Map customFields;
public static final String SERIALIZED_NAME_DESCRIPTION = "description";
@SerializedName(SERIALIZED_NAME_DESCRIPTION)
private String description;
public static final String SERIALIZED_NAME_EXISTING_ACCOUNT_NUMBER = "existingAccountNumber";
@SerializedName(SERIALIZED_NAME_EXISTING_ACCOUNT_NUMBER)
private String existingAccountNumber;
public static final String SERIALIZED_NAME_ORDER_DATE = "orderDate";
@SerializedName(SERIALIZED_NAME_ORDER_DATE)
private LocalDate orderDate;
public static final String SERIALIZED_NAME_ORDER_LINE_ITEMS = "orderLineItems";
@SerializedName(SERIALIZED_NAME_ORDER_LINE_ITEMS)
private List orderLineItems;
public static final String SERIALIZED_NAME_ORDER_NUMBER = "orderNumber";
@SerializedName(SERIALIZED_NAME_ORDER_NUMBER)
private String orderNumber;
public static final String SERIALIZED_NAME_PREVIEW_ACCOUNT_INFO = "previewAccountInfo";
@SerializedName(SERIALIZED_NAME_PREVIEW_ACCOUNT_INFO)
private PreviewAccountInfo previewAccountInfo;
public static final String SERIALIZED_NAME_PREVIEW_OPTIONS = "previewOptions";
@SerializedName(SERIALIZED_NAME_PREVIEW_OPTIONS)
private PreviewOptions previewOptions;
public static final String SERIALIZED_NAME_REASON_CODE = "reasonCode";
@SerializedName(SERIALIZED_NAME_REASON_CODE)
private String reasonCode;
public static final String SERIALIZED_NAME_SUBSCRIPTIONS = "subscriptions";
@SerializedName(SERIALIZED_NAME_SUBSCRIPTIONS)
private List subscriptions;
public PreviewOrderRequest() {
}
public PreviewOrderRequest category(OrderCategory category) {
this.category = category;
return this;
}
/**
* Get category
* @return category
*/
@javax.annotation.Nullable
public OrderCategory getCategory() {
return category;
}
public void setCategory(OrderCategory category) {
this.category = category;
}
public PreviewOrderRequest customFields(Map customFields) {
this.customFields = customFields;
return this;
}
public PreviewOrderRequest putCustomFieldsItem(String key, Object customFieldsItem) {
if (this.customFields == null) {
this.customFields = new HashMap<>();
}
this.customFields.put(key, customFieldsItem);
return this;
}
/**
* Container for custom fields of an Order object.
* @return customFields
*/
@javax.annotation.Nullable
public Map getCustomFields() {
return customFields;
}
public void setCustomFields(Map customFields) {
this.customFields = customFields;
}
public PreviewOrderRequest description(String description) {
this.description = description;
return this;
}
/**
* A description of the order.
* @return description
*/
@javax.annotation.Nullable
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public PreviewOrderRequest existingAccountNumber(String existingAccountNumber) {
this.existingAccountNumber = existingAccountNumber;
return this;
}
/**
* The account number that this order will be created under. It can be either the accountNumber or the account info. It will return an error if both are specified. Note that invoice owner account of the subscriptions included in this order should be the same with the account of the order.
* @return existingAccountNumber
*/
@javax.annotation.Nullable
public String getExistingAccountNumber() {
return existingAccountNumber;
}
public void setExistingAccountNumber(String existingAccountNumber) {
this.existingAccountNumber = existingAccountNumber;
}
public PreviewOrderRequest orderDate(LocalDate orderDate) {
this.orderDate = orderDate;
return this;
}
/**
* The date when the order is signed. All of the order actions under this order will use this order date as the contract effective date.
* @return orderDate
*/
@javax.annotation.Nonnull
public LocalDate getOrderDate() {
return orderDate;
}
public void setOrderDate(LocalDate orderDate) {
this.orderDate = orderDate;
}
public PreviewOrderRequest orderLineItems(List orderLineItems) {
this.orderLineItems = orderLineItems;
return this;
}
public PreviewOrderRequest addOrderLineItemsItem(CreateOrderOrderLineItem orderLineItemsItem) {
if (this.orderLineItems == null) {
this.orderLineItems = new ArrayList<>();
}
this.orderLineItems.add(orderLineItemsItem);
return this;
}
/**
* [Order Line Items](https://knowledgecenter.zuora.com/Billing/Subscriptions/Orders/Order_Line_Items/AA_Overview_of_Order_Line_Items) are non subscription based items created by an Order, representing transactional charges such as one-time fees, physical goods, or professional service charges that are not sold as subscription services. With the Order Line Items feature enabled, you can now launch non-subscription and unified monetization business models in Zuora, in addition to subscription business models. **Note:** The [Order Line Items](https://knowledgecenter.zuora.com/Billing/Subscriptions/Orders/Order_Line_Items/AA_Overview_of_Order_Line_Items) feature is now generally available to all Zuora customers. You need to enable the [Orders](https://knowledgecenter.zuora.com/BC_Subscription_Management/Orders/AA_Overview_of_Orders#Orders) feature to access the [Order Line Items](https://knowledgecenter.zuora.com/Billing/Subscriptions/Orders/Order_Line_Items/AA_Overview_of_Order_Line_Items) feature. As of Zuora Billing Release 313 (November 2021), new customers who onboard on [Orders](https://knowledgecenter.zuora.com/Billing/Subscriptions/Orders/AA_Overview_of_Orders) will have the [Order Line Items](https://knowledgecenter.zuora.com/Billing/Subscriptions/Orders/Order_Line_Items) feature enabled by default.
* @return orderLineItems
*/
@javax.annotation.Nullable
public List getOrderLineItems() {
return orderLineItems;
}
public void setOrderLineItems(List orderLineItems) {
this.orderLineItems = orderLineItems;
}
public PreviewOrderRequest orderNumber(String orderNumber) {
this.orderNumber = orderNumber;
return this;
}
/**
* The order number of this order. **Note:** Make sure the order number does not contain a slash.
* @return orderNumber
*/
@javax.annotation.Nullable
public String getOrderNumber() {
return orderNumber;
}
public void setOrderNumber(String orderNumber) {
this.orderNumber = orderNumber;
}
public PreviewOrderRequest previewAccountInfo(PreviewAccountInfo previewAccountInfo) {
this.previewAccountInfo = previewAccountInfo;
return this;
}
/**
* Get previewAccountInfo
* @return previewAccountInfo
*/
@javax.annotation.Nullable
public PreviewAccountInfo getPreviewAccountInfo() {
return previewAccountInfo;
}
public void setPreviewAccountInfo(PreviewAccountInfo previewAccountInfo) {
this.previewAccountInfo = previewAccountInfo;
}
public PreviewOrderRequest previewOptions(PreviewOptions previewOptions) {
this.previewOptions = previewOptions;
return this;
}
/**
* Get previewOptions
* @return previewOptions
*/
@javax.annotation.Nonnull
public PreviewOptions getPreviewOptions() {
return previewOptions;
}
public void setPreviewOptions(PreviewOptions previewOptions) {
this.previewOptions = previewOptions;
}
public PreviewOrderRequest reasonCode(String reasonCode) {
this.reasonCode = reasonCode;
return this;
}
/**
* Values of reason code configured in **Billing Settings** > **Configure Reason Codes** through Zuora UI. Indicates the reason when a return order line item occurs.
* @return reasonCode
*/
@javax.annotation.Nullable
public String getReasonCode() {
return reasonCode;
}
public void setReasonCode(String reasonCode) {
this.reasonCode = reasonCode;
}
public PreviewOrderRequest subscriptions(List subscriptions) {
this.subscriptions = subscriptions;
return this;
}
public PreviewOrderRequest addSubscriptionsItem(PreviewOrderSubscriptions subscriptionsItem) {
if (this.subscriptions == null) {
this.subscriptions = new ArrayList<>();
}
this.subscriptions.add(subscriptionsItem);
return this;
}
/**
* Each item includes a set of order actions, which will be applied to the same base subscription.
* @return subscriptions
*/
@javax.annotation.Nullable
public List getSubscriptions() {
return subscriptions;
}
public void setSubscriptions(List subscriptions) {
this.subscriptions = subscriptions;
}
/**
* 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 PreviewOrderRequest instance itself
*/
public PreviewOrderRequest 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;
}
PreviewOrderRequest previewOrderRequest = (PreviewOrderRequest) o;
return Objects.equals(this.category, previewOrderRequest.category) &&
Objects.equals(this.customFields, previewOrderRequest.customFields) &&
Objects.equals(this.description, previewOrderRequest.description) &&
Objects.equals(this.existingAccountNumber, previewOrderRequest.existingAccountNumber) &&
Objects.equals(this.orderDate, previewOrderRequest.orderDate) &&
Objects.equals(this.orderLineItems, previewOrderRequest.orderLineItems) &&
Objects.equals(this.orderNumber, previewOrderRequest.orderNumber) &&
Objects.equals(this.previewAccountInfo, previewOrderRequest.previewAccountInfo) &&
Objects.equals(this.previewOptions, previewOrderRequest.previewOptions) &&
Objects.equals(this.reasonCode, previewOrderRequest.reasonCode) &&
Objects.equals(this.subscriptions, previewOrderRequest.subscriptions)&&
Objects.equals(this.additionalProperties, previewOrderRequest.additionalProperties);
}
@Override
public int hashCode() {
return Objects.hash(category, customFields, description, existingAccountNumber, orderDate, orderLineItems, orderNumber, previewAccountInfo, previewOptions, reasonCode, subscriptions, additionalProperties);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class PreviewOrderRequest {\n");
sb.append(" category: ").append(toIndentedString(category)).append("\n");
sb.append(" customFields: ").append(toIndentedString(customFields)).append("\n");
sb.append(" description: ").append(toIndentedString(description)).append("\n");
sb.append(" existingAccountNumber: ").append(toIndentedString(existingAccountNumber)).append("\n");
sb.append(" orderDate: ").append(toIndentedString(orderDate)).append("\n");
sb.append(" orderLineItems: ").append(toIndentedString(orderLineItems)).append("\n");
sb.append(" orderNumber: ").append(toIndentedString(orderNumber)).append("\n");
sb.append(" previewAccountInfo: ").append(toIndentedString(previewAccountInfo)).append("\n");
sb.append(" previewOptions: ").append(toIndentedString(previewOptions)).append("\n");
sb.append(" reasonCode: ").append(toIndentedString(reasonCode)).append("\n");
sb.append(" subscriptions: ").append(toIndentedString(subscriptions)).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("category");
openapiFields.add("customFields");
openapiFields.add("description");
openapiFields.add("existingAccountNumber");
openapiFields.add("orderDate");
openapiFields.add("orderLineItems");
openapiFields.add("orderNumber");
openapiFields.add("previewAccountInfo");
openapiFields.add("previewOptions");
openapiFields.add("reasonCode");
openapiFields.add("subscriptions");
// a set of required properties/fields (JSON key names)
openapiRequiredFields = new HashSet();
openapiRequiredFields.add("orderDate");
openapiRequiredFields.add("previewOptions");
}
/**
* 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 PreviewOrderRequest
*/
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
if (jsonElement == null) {
if (!PreviewOrderRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in PreviewOrderRequest is not found in the empty JSON string", PreviewOrderRequest.openapiRequiredFields.toString()));
}
}
// check to make sure all required properties/fields are present in the JSON string
for (String requiredField : PreviewOrderRequest.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();
// validate the optional field `category`
if (jsonObj.get("category") != null && !jsonObj.get("category").isJsonNull()) {
OrderCategory.validateJsonElement(jsonObj.get("category"));
}
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("existingAccountNumber") != null && !jsonObj.get("existingAccountNumber").isJsonNull()) && !jsonObj.get("existingAccountNumber").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `existingAccountNumber` to be a primitive type in the JSON string but got `%s`", jsonObj.get("existingAccountNumber").toString()));
}
if (jsonObj.get("orderLineItems") != null && !jsonObj.get("orderLineItems").isJsonNull()) {
JsonArray jsonArrayorderLineItems = jsonObj.getAsJsonArray("orderLineItems");
if (jsonArrayorderLineItems != null) {
// ensure the json data is an array
if (!jsonObj.get("orderLineItems").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `orderLineItems` to be an array in the JSON string but got `%s`", jsonObj.get("orderLineItems").toString()));
}
// validate the optional field `orderLineItems` (array)
for (int i = 0; i < jsonArrayorderLineItems.size(); i++) {
CreateOrderOrderLineItem.validateJsonElement(jsonArrayorderLineItems.get(i));
};
}
}
if ((jsonObj.get("orderNumber") != null && !jsonObj.get("orderNumber").isJsonNull()) && !jsonObj.get("orderNumber").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `orderNumber` to be a primitive type in the JSON string but got `%s`", jsonObj.get("orderNumber").toString()));
}
// validate the optional field `previewAccountInfo`
if (jsonObj.get("previewAccountInfo") != null && !jsonObj.get("previewAccountInfo").isJsonNull()) {
PreviewAccountInfo.validateJsonElement(jsonObj.get("previewAccountInfo"));
}
// validate the required field `previewOptions`
PreviewOptions.validateJsonElement(jsonObj.get("previewOptions"));
if ((jsonObj.get("reasonCode") != null && !jsonObj.get("reasonCode").isJsonNull()) && !jsonObj.get("reasonCode").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `reasonCode` to be a primitive type in the JSON string but got `%s`", jsonObj.get("reasonCode").toString()));
}
if (jsonObj.get("subscriptions") != null && !jsonObj.get("subscriptions").isJsonNull()) {
JsonArray jsonArraysubscriptions = jsonObj.getAsJsonArray("subscriptions");
if (jsonArraysubscriptions != null) {
// ensure the json data is an array
if (!jsonObj.get("subscriptions").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `subscriptions` to be an array in the JSON string but got `%s`", jsonObj.get("subscriptions").toString()));
}
// validate the optional field `subscriptions` (array)
for (int i = 0; i < jsonArraysubscriptions.size(); i++) {
PreviewOrderSubscriptions.validateJsonElement(jsonArraysubscriptions.get(i));
};
}
}
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@SuppressWarnings("unchecked")
@Override
public TypeAdapter create(Gson gson, TypeToken type) {
if (!PreviewOrderRequest.class.isAssignableFrom(type.getRawType())) {
return null; // this class only serializes 'PreviewOrderRequest' and its subtypes
}
final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
final TypeAdapter thisAdapter
= gson.getDelegateAdapter(this, TypeToken.get(PreviewOrderRequest.class));
return (TypeAdapter) new TypeAdapter() {
@Override
public void write(JsonWriter out, PreviewOrderRequest 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 PreviewOrderRequest read(JsonReader in) throws IOException {
JsonElement jsonElement = elementAdapter.read(in);
validateJsonElement(jsonElement);
JsonObject jsonObj = jsonElement.getAsJsonObject();
// store additional fields in the deserialized instance
PreviewOrderRequest 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 PreviewOrderRequest given an JSON string
*
* @param jsonString JSON string
* @return An instance of PreviewOrderRequest
* @throws IOException if the JSON string is invalid with respect to PreviewOrderRequest
*/
public static PreviewOrderRequest fromJson(String jsonString) throws IOException {
return JSON.getGson().fromJson(jsonString, PreviewOrderRequest.class);
}
/**
* Convert an instance of PreviewOrderRequest to an JSON string
*
* @return JSON string
*/
public String toJson() {
return JSON.getGson().toJson(this);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy