com.zuora.model.UpdateOrderRequest 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.CreateOrderSubscription;
import com.zuora.model.ExternallyManagedBy;
import com.zuora.model.OrderCategory;
import com.zuora.model.OrderCreateAccount;
import com.zuora.model.OrderSchedulingOptions;
import com.zuora.model.OrderStatus;
import com.zuora.model.ProcessingOptions;
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;
/**
* UpdateOrderRequest
*/
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.6.0")
public class UpdateOrderRequest {
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_EXTERNALLY_MANAGED_BY = "externallyManagedBy";
@SerializedName(SERIALIZED_NAME_EXTERNALLY_MANAGED_BY)
private ExternallyManagedBy externallyManagedBy;
public static final String SERIALIZED_NAME_NEW_ACCOUNT = "newAccount";
@SerializedName(SERIALIZED_NAME_NEW_ACCOUNT)
private OrderCreateAccount newAccount;
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_PROCESSING_OPTIONS = "processingOptions";
@SerializedName(SERIALIZED_NAME_PROCESSING_OPTIONS)
private ProcessingOptions processingOptions;
public static final String SERIALIZED_NAME_REASON_CODE = "reasonCode";
@SerializedName(SERIALIZED_NAME_REASON_CODE)
private String reasonCode;
public static final String SERIALIZED_NAME_SCHEDULING_OPTIONS = "schedulingOptions";
@SerializedName(SERIALIZED_NAME_SCHEDULING_OPTIONS)
private OrderSchedulingOptions schedulingOptions;
public static final String SERIALIZED_NAME_STATUS = "status";
@SerializedName(SERIALIZED_NAME_STATUS)
private OrderStatus status;
public static final String SERIALIZED_NAME_SUBSCRIPTIONS = "subscriptions";
@SerializedName(SERIALIZED_NAME_SUBSCRIPTIONS)
private List subscriptions;
public UpdateOrderRequest() {
}
public UpdateOrderRequest 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 UpdateOrderRequest customFields(Map customFields) {
this.customFields = customFields;
return this;
}
public UpdateOrderRequest 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 UpdateOrderRequest 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 UpdateOrderRequest 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 provided. It will return an error if both are specified. Note that this actually specifies the invoice owner account of the subscriptions included in this order.
* @return existingAccountNumber
*/
@javax.annotation.Nullable
public String getExistingAccountNumber() {
return existingAccountNumber;
}
public void setExistingAccountNumber(String existingAccountNumber) {
this.existingAccountNumber = existingAccountNumber;
}
public UpdateOrderRequest externallyManagedBy(ExternallyManagedBy externallyManagedBy) {
this.externallyManagedBy = externallyManagedBy;
return this;
}
/**
* Get externallyManagedBy
* @return externallyManagedBy
*/
@javax.annotation.Nullable
public ExternallyManagedBy getExternallyManagedBy() {
return externallyManagedBy;
}
public void setExternallyManagedBy(ExternallyManagedBy externallyManagedBy) {
this.externallyManagedBy = externallyManagedBy;
}
public UpdateOrderRequest newAccount(OrderCreateAccount newAccount) {
this.newAccount = newAccount;
return this;
}
/**
* Get newAccount
* @return newAccount
*/
@javax.annotation.Nullable
public OrderCreateAccount getNewAccount() {
return newAccount;
}
public void setNewAccount(OrderCreateAccount newAccount) {
this.newAccount = newAccount;
}
public UpdateOrderRequest orderDate(LocalDate orderDate) {
this.orderDate = orderDate;
return this;
}
/**
* The date when the order is signed. All the order actions under this order will use this order date as the contract effective date if the contract effective date field is skipped or its value is left as null.
* @return orderDate
*/
@javax.annotation.Nonnull
public LocalDate getOrderDate() {
return orderDate;
}
public void setOrderDate(LocalDate orderDate) {
this.orderDate = orderDate;
}
public UpdateOrderRequest orderLineItems(List orderLineItems) {
this.orderLineItems = orderLineItems;
return this;
}
public UpdateOrderRequest 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 UpdateOrderRequest orderNumber(String orderNumber) {
this.orderNumber = orderNumber;
return this;
}
/**
* The order number of the new order. If not provided, system will auto-generate a number for 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 UpdateOrderRequest processingOptions(ProcessingOptions processingOptions) {
this.processingOptions = processingOptions;
return this;
}
/**
* Get processingOptions
* @return processingOptions
*/
@javax.annotation.Nullable
public ProcessingOptions getProcessingOptions() {
return processingOptions;
}
public void setProcessingOptions(ProcessingOptions processingOptions) {
this.processingOptions = processingOptions;
}
public UpdateOrderRequest 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 UpdateOrderRequest schedulingOptions(OrderSchedulingOptions schedulingOptions) {
this.schedulingOptions = schedulingOptions;
return this;
}
/**
* Get schedulingOptions
* @return schedulingOptions
*/
@javax.annotation.Nullable
public OrderSchedulingOptions getSchedulingOptions() {
return schedulingOptions;
}
public void setSchedulingOptions(OrderSchedulingOptions schedulingOptions) {
this.schedulingOptions = schedulingOptions;
}
public UpdateOrderRequest status(OrderStatus status) {
this.status = status;
return this;
}
/**
* Get status
* @return status
*/
@javax.annotation.Nullable
public OrderStatus getStatus() {
return status;
}
public void setStatus(OrderStatus status) {
this.status = status;
}
public UpdateOrderRequest subscriptions(List subscriptions) {
this.subscriptions = subscriptions;
return this;
}
public UpdateOrderRequest addSubscriptionsItem(CreateOrderSubscription 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 UpdateOrderRequest instance itself
*/
public UpdateOrderRequest 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;
}
UpdateOrderRequest updateOrderRequest = (UpdateOrderRequest) o;
return Objects.equals(this.category, updateOrderRequest.category) &&
Objects.equals(this.customFields, updateOrderRequest.customFields) &&
Objects.equals(this.description, updateOrderRequest.description) &&
Objects.equals(this.existingAccountNumber, updateOrderRequest.existingAccountNumber) &&
Objects.equals(this.externallyManagedBy, updateOrderRequest.externallyManagedBy) &&
Objects.equals(this.newAccount, updateOrderRequest.newAccount) &&
Objects.equals(this.orderDate, updateOrderRequest.orderDate) &&
Objects.equals(this.orderLineItems, updateOrderRequest.orderLineItems) &&
Objects.equals(this.orderNumber, updateOrderRequest.orderNumber) &&
Objects.equals(this.processingOptions, updateOrderRequest.processingOptions) &&
Objects.equals(this.reasonCode, updateOrderRequest.reasonCode) &&
Objects.equals(this.schedulingOptions, updateOrderRequest.schedulingOptions) &&
Objects.equals(this.status, updateOrderRequest.status) &&
Objects.equals(this.subscriptions, updateOrderRequest.subscriptions)&&
Objects.equals(this.additionalProperties, updateOrderRequest.additionalProperties);
}
@Override
public int hashCode() {
return Objects.hash(category, customFields, description, existingAccountNumber, externallyManagedBy, newAccount, orderDate, orderLineItems, orderNumber, processingOptions, reasonCode, schedulingOptions, status, subscriptions, additionalProperties);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class UpdateOrderRequest {\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(" externallyManagedBy: ").append(toIndentedString(externallyManagedBy)).append("\n");
sb.append(" newAccount: ").append(toIndentedString(newAccount)).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(" processingOptions: ").append(toIndentedString(processingOptions)).append("\n");
sb.append(" reasonCode: ").append(toIndentedString(reasonCode)).append("\n");
sb.append(" schedulingOptions: ").append(toIndentedString(schedulingOptions)).append("\n");
sb.append(" status: ").append(toIndentedString(status)).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("externallyManagedBy");
openapiFields.add("newAccount");
openapiFields.add("orderDate");
openapiFields.add("orderLineItems");
openapiFields.add("orderNumber");
openapiFields.add("processingOptions");
openapiFields.add("reasonCode");
openapiFields.add("schedulingOptions");
openapiFields.add("status");
openapiFields.add("subscriptions");
// a set of required properties/fields (JSON key names)
openapiRequiredFields = new HashSet();
openapiRequiredFields.add("orderDate");
}
/**
* 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 UpdateOrderRequest
*/
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
if (jsonElement == null) {
if (!UpdateOrderRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in UpdateOrderRequest is not found in the empty JSON string", UpdateOrderRequest.openapiRequiredFields.toString()));
}
}
// check to make sure all required properties/fields are present in the JSON string
for (String requiredField : UpdateOrderRequest.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("externallyManagedBy") != null && !jsonObj.get("externallyManagedBy").isJsonNull()) && !jsonObj.get("externallyManagedBy").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `externallyManagedBy` to be a primitive type in the JSON string but got `%s`", jsonObj.get("externallyManagedBy").toString()));
}
// validate the optional field `externallyManagedBy`
if (jsonObj.get("externallyManagedBy") != null && !jsonObj.get("externallyManagedBy").isJsonNull()) {
ExternallyManagedBy.validateJsonElement(jsonObj.get("externallyManagedBy"));
}
// validate the optional field `newAccount`
if (jsonObj.get("newAccount") != null && !jsonObj.get("newAccount").isJsonNull()) {
OrderCreateAccount.validateJsonElement(jsonObj.get("newAccount"));
}
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 `processingOptions`
if (jsonObj.get("processingOptions") != null && !jsonObj.get("processingOptions").isJsonNull()) {
ProcessingOptions.validateJsonElement(jsonObj.get("processingOptions"));
}
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()));
}
// validate the optional field `schedulingOptions`
if (jsonObj.get("schedulingOptions") != null && !jsonObj.get("schedulingOptions").isJsonNull()) {
OrderSchedulingOptions.validateJsonElement(jsonObj.get("schedulingOptions"));
}
if ((jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) && !jsonObj.get("status").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString()));
}
// validate the optional field `status`
if (jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) {
OrderStatus.validateJsonElement(jsonObj.get("status"));
}
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++) {
CreateOrderSubscription.validateJsonElement(jsonArraysubscriptions.get(i));
};
}
}
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@SuppressWarnings("unchecked")
@Override
public TypeAdapter create(Gson gson, TypeToken type) {
if (!UpdateOrderRequest.class.isAssignableFrom(type.getRawType())) {
return null; // this class only serializes 'UpdateOrderRequest' and its subtypes
}
final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
final TypeAdapter thisAdapter
= gson.getDelegateAdapter(this, TypeToken.get(UpdateOrderRequest.class));
return (TypeAdapter) new TypeAdapter() {
@Override
public void write(JsonWriter out, UpdateOrderRequest 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 UpdateOrderRequest read(JsonReader in) throws IOException {
JsonElement jsonElement = elementAdapter.read(in);
validateJsonElement(jsonElement);
JsonObject jsonObj = jsonElement.getAsJsonObject();
// store additional fields in the deserialized instance
UpdateOrderRequest 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 UpdateOrderRequest given an JSON string
*
* @param jsonString JSON string
* @return An instance of UpdateOrderRequest
* @throws IOException if the JSON string is invalid with respect to UpdateOrderRequest
*/
public static UpdateOrderRequest fromJson(String jsonString) throws IOException {
return JSON.getGson().fromJson(jsonString, UpdateOrderRequest.class);
}
/**
* Convert an instance of UpdateOrderRequest to an JSON string
*
* @return JSON string
*/
public String toJson() {
return JSON.getGson().toJson(this);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy