com.zuora.model.UpdateSubscriptionResponse 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.ChargeMetrics;
import com.zuora.model.PreviewSubscriptionInvoice;
import com.zuora.model.PreviewSubscriptionInvoiceItem;
import com.zuora.model.SubscriptionCreditMemo;
import java.io.IOException;
import java.math.BigDecimal;
import java.time.LocalDate;
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;
/**
* UpdateSubscriptionResponse
*/
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.6.0")
public class UpdateSubscriptionResponse {
public static final String SERIALIZED_NAME_AMOUNT = "amount";
@Deprecated
@SerializedName(SERIALIZED_NAME_AMOUNT)
private BigDecimal amount;
public static final String SERIALIZED_NAME_AMOUNT_WITHOUT_TAX = "amountWithoutTax";
@Deprecated
@SerializedName(SERIALIZED_NAME_AMOUNT_WITHOUT_TAX)
private BigDecimal amountWithoutTax;
public static final String SERIALIZED_NAME_CHARGE_METRICS = "chargeMetrics";
@SerializedName(SERIALIZED_NAME_CHARGE_METRICS)
private ChargeMetrics chargeMetrics;
public static final String SERIALIZED_NAME_CREDIT_MEMO = "creditMemo";
@SerializedName(SERIALIZED_NAME_CREDIT_MEMO)
private SubscriptionCreditMemo creditMemo;
public static final String SERIALIZED_NAME_CREDIT_MEMO_ID = "creditMemoId";
@SerializedName(SERIALIZED_NAME_CREDIT_MEMO_ID)
private String creditMemoId;
public static final String SERIALIZED_NAME_INVOICE = "invoice";
@SerializedName(SERIALIZED_NAME_INVOICE)
private PreviewSubscriptionInvoice invoice;
public static final String SERIALIZED_NAME_INVOICE_ID = "invoiceId";
@SerializedName(SERIALIZED_NAME_INVOICE_ID)
private String invoiceId;
public static final String SERIALIZED_NAME_INVOICE_ITEMS = "invoiceItems";
@Deprecated
@SerializedName(SERIALIZED_NAME_INVOICE_ITEMS)
private List invoiceItems;
public static final String SERIALIZED_NAME_INVOICE_TARGET_DATE = "invoiceTargetDate";
@Deprecated
@SerializedName(SERIALIZED_NAME_INVOICE_TARGET_DATE)
private LocalDate invoiceTargetDate;
public static final String SERIALIZED_NAME_PAID_AMOUNT = "paidAmount";
@SerializedName(SERIALIZED_NAME_PAID_AMOUNT)
private BigDecimal paidAmount;
public static final String SERIALIZED_NAME_PAYMENT_ID = "paymentId";
@SerializedName(SERIALIZED_NAME_PAYMENT_ID)
private String paymentId;
public static final String SERIALIZED_NAME_SUBSCRIPTION_ID = "subscriptionId";
@SerializedName(SERIALIZED_NAME_SUBSCRIPTION_ID)
private String subscriptionId;
public static final String SERIALIZED_NAME_SUCCESS = "success";
@SerializedName(SERIALIZED_NAME_SUCCESS)
private Boolean success;
public static final String SERIALIZED_NAME_TARGET_DATE = "targetDate";
@SerializedName(SERIALIZED_NAME_TARGET_DATE)
private LocalDate targetDate;
public static final String SERIALIZED_NAME_TAX_AMOUNT = "taxAmount";
@Deprecated
@SerializedName(SERIALIZED_NAME_TAX_AMOUNT)
private BigDecimal taxAmount;
public static final String SERIALIZED_NAME_TOTAL_DELTA_MRR = "totalDeltaMrr";
@SerializedName(SERIALIZED_NAME_TOTAL_DELTA_MRR)
private BigDecimal totalDeltaMrr;
public static final String SERIALIZED_NAME_TOTAL_DELTA_TCV = "totalDeltaTcv";
@SerializedName(SERIALIZED_NAME_TOTAL_DELTA_TCV)
private BigDecimal totalDeltaTcv;
public static final String SERIALIZED_NAME_ORDER_NUMBERS = "orderNumbers";
@SerializedName(SERIALIZED_NAME_ORDER_NUMBERS)
private List orderNumbers;
public UpdateSubscriptionResponse() {
}
@Deprecated
public UpdateSubscriptionResponse amount(BigDecimal amount) {
this.amount = amount;
return this;
}
/**
* Invoice amount. Preview mode only. This field is in Zuora REST API version control. Supported minor versions are `206.0` and earlier. It is moved to this **invoice** container after 206.0
* @return amount
* @deprecated
*/
@Deprecated
@javax.annotation.Nullable
public BigDecimal getAmount() {
return amount;
}
@Deprecated
public void setAmount(BigDecimal amount) {
this.amount = amount;
}
@Deprecated
public UpdateSubscriptionResponse amountWithoutTax(BigDecimal amountWithoutTax) {
this.amountWithoutTax = amountWithoutTax;
return this;
}
/**
* Invoice amount minus tax. Preview mode only. This field is in Zuora REST API version control. Supported minor versions are `206.0` and earlier. It is moved to this **invoice** container after 206.0
* @return amountWithoutTax
* @deprecated
*/
@Deprecated
@javax.annotation.Nullable
public BigDecimal getAmountWithoutTax() {
return amountWithoutTax;
}
@Deprecated
public void setAmountWithoutTax(BigDecimal amountWithoutTax) {
this.amountWithoutTax = amountWithoutTax;
}
public UpdateSubscriptionResponse chargeMetrics(ChargeMetrics chargeMetrics) {
this.chargeMetrics = chargeMetrics;
return this;
}
/**
* Get chargeMetrics
* @return chargeMetrics
*/
@javax.annotation.Nullable
public ChargeMetrics getChargeMetrics() {
return chargeMetrics;
}
public void setChargeMetrics(ChargeMetrics chargeMetrics) {
this.chargeMetrics = chargeMetrics;
}
public UpdateSubscriptionResponse creditMemo(SubscriptionCreditMemo creditMemo) {
this.creditMemo = creditMemo;
return this;
}
/**
* Get creditMemo
* @return creditMemo
*/
@javax.annotation.Nullable
public SubscriptionCreditMemo getCreditMemo() {
return creditMemo;
}
public void setCreditMemo(SubscriptionCreditMemo creditMemo) {
this.creditMemo = creditMemo;
}
public UpdateSubscriptionResponse creditMemoId(String creditMemoId) {
this.creditMemoId = creditMemoId;
return this;
}
/**
* The credit memo ID, if a credit memo is generated during the subscription process. **Note:** This container is only available if you set the Zuora REST API minor version to 207.0 or later in the request header, and you have [Invoice Settlement](https://knowledgecenter.zuora.com/Billing/Billing_and_Payments/Invoice_Settlement) enabled. The Invoice Settlement feature is generally available as of Zuora Billing Release 296 (March 2021). This feature includes Unapplied Payments, Credit and Debit Memo, and Invoice Item Settlement. If you want to enable Invoice Settlement, see [Invoice Settlement Enablement and Checklist Guide](https://knowledgecenter.zuora.com/Billing/Billing_and_Payments/Invoice_Settlement/Invoice_Settlement_Migration_Checklist_and_Guide) for more information.
* @return creditMemoId
*/
@javax.annotation.Nullable
public String getCreditMemoId() {
return creditMemoId;
}
public void setCreditMemoId(String creditMemoId) {
this.creditMemoId = creditMemoId;
}
public UpdateSubscriptionResponse invoice(PreviewSubscriptionInvoice invoice) {
this.invoice = invoice;
return this;
}
/**
* Get invoice
* @return invoice
*/
@javax.annotation.Nullable
public PreviewSubscriptionInvoice getInvoice() {
return invoice;
}
public void setInvoice(PreviewSubscriptionInvoice invoice) {
this.invoice = invoice;
}
public UpdateSubscriptionResponse invoiceId(String invoiceId) {
this.invoiceId = invoiceId;
return this;
}
/**
* Invoice ID, if an invoice is generated during the update.
* @return invoiceId
*/
@javax.annotation.Nullable
public String getInvoiceId() {
return invoiceId;
}
public void setInvoiceId(String invoiceId) {
this.invoiceId = invoiceId;
}
@Deprecated
public UpdateSubscriptionResponse invoiceItems(List invoiceItems) {
this.invoiceItems = invoiceItems;
return this;
}
public UpdateSubscriptionResponse addInvoiceItemsItem(PreviewSubscriptionInvoiceItem invoiceItemsItem) {
if (this.invoiceItems == null) {
this.invoiceItems = new ArrayList<>();
}
this.invoiceItems.add(invoiceItemsItem);
return this;
}
/**
* This field is only available REST API max version 206.0. Container for invoice items.
* @return invoiceItems
* @deprecated
*/
@Deprecated
@javax.annotation.Nullable
public List getInvoiceItems() {
return invoiceItems;
}
@Deprecated
public void setInvoiceItems(List invoiceItems) {
this.invoiceItems = invoiceItems;
}
@Deprecated
public UpdateSubscriptionResponse invoiceTargetDate(LocalDate invoiceTargetDate) {
this.invoiceTargetDate = invoiceTargetDate;
return this;
}
/**
* Date through which charges are calculated on the invoice, as yyyy-mm-dd. Preview mode only. **Note:** This field is only available if you do not specify the Zuora REST API minor version or specify the minor version to 186.0, 187.0, 188.0, 189.0, and 196.0. See [Zuora REST API Versions](https://www.zuora.com/developer/api-references/api/overview/#section/API-Versions) for more information.
* @return invoiceTargetDate
* @deprecated
*/
@Deprecated
@javax.annotation.Nullable
public LocalDate getInvoiceTargetDate() {
return invoiceTargetDate;
}
@Deprecated
public void setInvoiceTargetDate(LocalDate invoiceTargetDate) {
this.invoiceTargetDate = invoiceTargetDate;
}
public UpdateSubscriptionResponse paidAmount(BigDecimal paidAmount) {
this.paidAmount = paidAmount;
return this;
}
/**
* Payment amount, if a payment is collected
* @return paidAmount
*/
@javax.annotation.Nullable
public BigDecimal getPaidAmount() {
return paidAmount;
}
public void setPaidAmount(BigDecimal paidAmount) {
this.paidAmount = paidAmount;
}
public UpdateSubscriptionResponse paymentId(String paymentId) {
this.paymentId = paymentId;
return this;
}
/**
* Payment ID, if a payment is collected.
* @return paymentId
*/
@javax.annotation.Nullable
public String getPaymentId() {
return paymentId;
}
public void setPaymentId(String paymentId) {
this.paymentId = paymentId;
}
public UpdateSubscriptionResponse subscriptionId(String subscriptionId) {
this.subscriptionId = subscriptionId;
return this;
}
/**
* The ID of the resulting new subscription.
* @return subscriptionId
*/
@javax.annotation.Nullable
public String getSubscriptionId() {
return subscriptionId;
}
public void setSubscriptionId(String subscriptionId) {
this.subscriptionId = subscriptionId;
}
public UpdateSubscriptionResponse success(Boolean success) {
this.success = success;
return this;
}
/**
* Returns `true` if the request was processed successfully.
* @return success
*/
@javax.annotation.Nullable
public Boolean getSuccess() {
return success;
}
public void setSuccess(Boolean success) {
this.success = success;
}
public UpdateSubscriptionResponse targetDate(LocalDate targetDate) {
this.targetDate = targetDate;
return this;
}
/**
* Date through which to calculate charges if an invoice is generated, as yyyy-mm-dd. Default is current date. **Note:** This field is only available if you set the Zuora REST API minor version to 207.0 or later in the request header. See [Zuora REST API Versions](https://www.zuora.com/developer/api-references/api/overview/#section/API-Versions) for more information.
* @return targetDate
*/
@javax.annotation.Nullable
public LocalDate getTargetDate() {
return targetDate;
}
public void setTargetDate(LocalDate targetDate) {
this.targetDate = targetDate;
}
@Deprecated
public UpdateSubscriptionResponse taxAmount(BigDecimal taxAmount) {
this.taxAmount = taxAmount;
return this;
}
/**
* Tax amount on the invoice. This field is in Zuora REST API version control. Supported minor versions are `206.0` and earlier. It is moved to this **invoice** container after 206.0
* @return taxAmount
* @deprecated
*/
@Deprecated
@javax.annotation.Nullable
public BigDecimal getTaxAmount() {
return taxAmount;
}
@Deprecated
public void setTaxAmount(BigDecimal taxAmount) {
this.taxAmount = taxAmount;
}
public UpdateSubscriptionResponse totalDeltaMrr(BigDecimal totalDeltaMrr) {
this.totalDeltaMrr = totalDeltaMrr;
return this;
}
/**
* Change in the subscription monthly recurring revenue as a result of the update.
* @return totalDeltaMrr
*/
@javax.annotation.Nullable
public BigDecimal getTotalDeltaMrr() {
return totalDeltaMrr;
}
public void setTotalDeltaMrr(BigDecimal totalDeltaMrr) {
this.totalDeltaMrr = totalDeltaMrr;
}
public UpdateSubscriptionResponse totalDeltaTcv(BigDecimal totalDeltaTcv) {
this.totalDeltaTcv = totalDeltaTcv;
return this;
}
/**
* Change in the total contracted value of the subscription as a result of the update.
* @return totalDeltaTcv
*/
@javax.annotation.Nullable
public BigDecimal getTotalDeltaTcv() {
return totalDeltaTcv;
}
public void setTotalDeltaTcv(BigDecimal totalDeltaTcv) {
this.totalDeltaTcv = totalDeltaTcv;
}
public UpdateSubscriptionResponse orderNumbers(List orderNumbers) {
this.orderNumbers = orderNumbers;
return this;
}
public UpdateSubscriptionResponse addOrderNumbersItem(String orderNumbersItem) {
if (this.orderNumbers == null) {
this.orderNumbers = new ArrayList<>();
}
this.orderNumbers.add(orderNumbersItem);
return this;
}
/**
* The order numbers. It is available for Orders Tenants.
* @return orderNumbers
*/
@javax.annotation.Nullable
public List getOrderNumbers() {
return orderNumbers;
}
public void setOrderNumbers(List orderNumbers) {
this.orderNumbers = orderNumbers;
}
/**
* 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 UpdateSubscriptionResponse instance itself
*/
public UpdateSubscriptionResponse 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;
}
UpdateSubscriptionResponse updateSubscriptionResponse = (UpdateSubscriptionResponse) o;
return Objects.equals(this.amount, updateSubscriptionResponse.amount) &&
Objects.equals(this.amountWithoutTax, updateSubscriptionResponse.amountWithoutTax) &&
Objects.equals(this.chargeMetrics, updateSubscriptionResponse.chargeMetrics) &&
Objects.equals(this.creditMemo, updateSubscriptionResponse.creditMemo) &&
Objects.equals(this.creditMemoId, updateSubscriptionResponse.creditMemoId) &&
Objects.equals(this.invoice, updateSubscriptionResponse.invoice) &&
Objects.equals(this.invoiceId, updateSubscriptionResponse.invoiceId) &&
Objects.equals(this.invoiceItems, updateSubscriptionResponse.invoiceItems) &&
Objects.equals(this.invoiceTargetDate, updateSubscriptionResponse.invoiceTargetDate) &&
Objects.equals(this.paidAmount, updateSubscriptionResponse.paidAmount) &&
Objects.equals(this.paymentId, updateSubscriptionResponse.paymentId) &&
Objects.equals(this.subscriptionId, updateSubscriptionResponse.subscriptionId) &&
Objects.equals(this.success, updateSubscriptionResponse.success) &&
Objects.equals(this.targetDate, updateSubscriptionResponse.targetDate) &&
Objects.equals(this.taxAmount, updateSubscriptionResponse.taxAmount) &&
Objects.equals(this.totalDeltaMrr, updateSubscriptionResponse.totalDeltaMrr) &&
Objects.equals(this.totalDeltaTcv, updateSubscriptionResponse.totalDeltaTcv) &&
Objects.equals(this.orderNumbers, updateSubscriptionResponse.orderNumbers)&&
Objects.equals(this.additionalProperties, updateSubscriptionResponse.additionalProperties);
}
@Override
public int hashCode() {
return Objects.hash(amount, amountWithoutTax, chargeMetrics, creditMemo, creditMemoId, invoice, invoiceId, invoiceItems, invoiceTargetDate, paidAmount, paymentId, subscriptionId, success, targetDate, taxAmount, totalDeltaMrr, totalDeltaTcv, orderNumbers, additionalProperties);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class UpdateSubscriptionResponse {\n");
sb.append(" amount: ").append(toIndentedString(amount)).append("\n");
sb.append(" amountWithoutTax: ").append(toIndentedString(amountWithoutTax)).append("\n");
sb.append(" chargeMetrics: ").append(toIndentedString(chargeMetrics)).append("\n");
sb.append(" creditMemo: ").append(toIndentedString(creditMemo)).append("\n");
sb.append(" creditMemoId: ").append(toIndentedString(creditMemoId)).append("\n");
sb.append(" invoice: ").append(toIndentedString(invoice)).append("\n");
sb.append(" invoiceId: ").append(toIndentedString(invoiceId)).append("\n");
sb.append(" invoiceItems: ").append(toIndentedString(invoiceItems)).append("\n");
sb.append(" invoiceTargetDate: ").append(toIndentedString(invoiceTargetDate)).append("\n");
sb.append(" paidAmount: ").append(toIndentedString(paidAmount)).append("\n");
sb.append(" paymentId: ").append(toIndentedString(paymentId)).append("\n");
sb.append(" subscriptionId: ").append(toIndentedString(subscriptionId)).append("\n");
sb.append(" success: ").append(toIndentedString(success)).append("\n");
sb.append(" targetDate: ").append(toIndentedString(targetDate)).append("\n");
sb.append(" taxAmount: ").append(toIndentedString(taxAmount)).append("\n");
sb.append(" totalDeltaMrr: ").append(toIndentedString(totalDeltaMrr)).append("\n");
sb.append(" totalDeltaTcv: ").append(toIndentedString(totalDeltaTcv)).append("\n");
sb.append(" orderNumbers: ").append(toIndentedString(orderNumbers)).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("amount");
openapiFields.add("amountWithoutTax");
openapiFields.add("chargeMetrics");
openapiFields.add("creditMemo");
openapiFields.add("creditMemoId");
openapiFields.add("invoice");
openapiFields.add("invoiceId");
openapiFields.add("invoiceItems");
openapiFields.add("invoiceTargetDate");
openapiFields.add("paidAmount");
openapiFields.add("paymentId");
openapiFields.add("subscriptionId");
openapiFields.add("success");
openapiFields.add("targetDate");
openapiFields.add("taxAmount");
openapiFields.add("totalDeltaMrr");
openapiFields.add("totalDeltaTcv");
openapiFields.add("orderNumbers");
// 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 UpdateSubscriptionResponse
*/
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
if (jsonElement == null) {
if (!UpdateSubscriptionResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in UpdateSubscriptionResponse is not found in the empty JSON string", UpdateSubscriptionResponse.openapiRequiredFields.toString()));
}
}
JsonObject jsonObj = jsonElement.getAsJsonObject();
// validate the optional field `chargeMetrics`
if (jsonObj.get("chargeMetrics") != null && !jsonObj.get("chargeMetrics").isJsonNull()) {
ChargeMetrics.validateJsonElement(jsonObj.get("chargeMetrics"));
}
// validate the optional field `creditMemo`
if (jsonObj.get("creditMemo") != null && !jsonObj.get("creditMemo").isJsonNull()) {
SubscriptionCreditMemo.validateJsonElement(jsonObj.get("creditMemo"));
}
if ((jsonObj.get("creditMemoId") != null && !jsonObj.get("creditMemoId").isJsonNull()) && !jsonObj.get("creditMemoId").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `creditMemoId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("creditMemoId").toString()));
}
// validate the optional field `invoice`
if (jsonObj.get("invoice") != null && !jsonObj.get("invoice").isJsonNull()) {
PreviewSubscriptionInvoice.validateJsonElement(jsonObj.get("invoice"));
}
if ((jsonObj.get("invoiceId") != null && !jsonObj.get("invoiceId").isJsonNull()) && !jsonObj.get("invoiceId").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `invoiceId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("invoiceId").toString()));
}
if (jsonObj.get("invoiceItems") != null && !jsonObj.get("invoiceItems").isJsonNull()) {
JsonArray jsonArrayinvoiceItems = jsonObj.getAsJsonArray("invoiceItems");
if (jsonArrayinvoiceItems != null) {
// ensure the json data is an array
if (!jsonObj.get("invoiceItems").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `invoiceItems` to be an array in the JSON string but got `%s`", jsonObj.get("invoiceItems").toString()));
}
// validate the optional field `invoiceItems` (array)
for (int i = 0; i < jsonArrayinvoiceItems.size(); i++) {
PreviewSubscriptionInvoiceItem.validateJsonElement(jsonArrayinvoiceItems.get(i));
};
}
}
if ((jsonObj.get("paymentId") != null && !jsonObj.get("paymentId").isJsonNull()) && !jsonObj.get("paymentId").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `paymentId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("paymentId").toString()));
}
if ((jsonObj.get("subscriptionId") != null && !jsonObj.get("subscriptionId").isJsonNull()) && !jsonObj.get("subscriptionId").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `subscriptionId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("subscriptionId").toString()));
}
// ensure the optional json data is an array if present
if (jsonObj.get("orderNumbers") != null && !jsonObj.get("orderNumbers").isJsonNull() && !jsonObj.get("orderNumbers").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `orderNumbers` to be an array in the JSON string but got `%s`", jsonObj.get("orderNumbers").toString()));
}
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@SuppressWarnings("unchecked")
@Override
public TypeAdapter create(Gson gson, TypeToken type) {
if (!UpdateSubscriptionResponse.class.isAssignableFrom(type.getRawType())) {
return null; // this class only serializes 'UpdateSubscriptionResponse' and its subtypes
}
final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
final TypeAdapter thisAdapter
= gson.getDelegateAdapter(this, TypeToken.get(UpdateSubscriptionResponse.class));
return (TypeAdapter) new TypeAdapter() {
@Override
public void write(JsonWriter out, UpdateSubscriptionResponse 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 UpdateSubscriptionResponse read(JsonReader in) throws IOException {
JsonElement jsonElement = elementAdapter.read(in);
validateJsonElement(jsonElement);
JsonObject jsonObj = jsonElement.getAsJsonObject();
// store additional fields in the deserialized instance
UpdateSubscriptionResponse 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 UpdateSubscriptionResponse given an JSON string
*
* @param jsonString JSON string
* @return An instance of UpdateSubscriptionResponse
* @throws IOException if the JSON string is invalid with respect to UpdateSubscriptionResponse
*/
public static UpdateSubscriptionResponse fromJson(String jsonString) throws IOException {
return JSON.getGson().fromJson(jsonString, UpdateSubscriptionResponse.class);
}
/**
* Convert an instance of UpdateSubscriptionResponse to an JSON string
*
* @return JSON string
*/
public String toJson() {
return JSON.getGson().toJson(this);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy