com.zuora.model.PreviewSubscriptionResponse 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;
/**
* PreviewSubscriptionResponse
*/
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.6.0")
public class PreviewSubscriptionResponse {
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 List chargeMetrics;
public static final String SERIALIZED_NAME_CONTRACTED_MRR = "contractedMrr";
@SerializedName(SERIALIZED_NAME_CONTRACTED_MRR)
private BigDecimal contractedMrr;
public static final String SERIALIZED_NAME_CREDIT_MEMO = "creditMemo";
@SerializedName(SERIALIZED_NAME_CREDIT_MEMO)
private SubscriptionCreditMemo creditMemo;
public static final String SERIALIZED_NAME_DOCUMENT_DATE = "documentDate";
@SerializedName(SERIALIZED_NAME_DOCUMENT_DATE)
private LocalDate documentDate;
public static final String SERIALIZED_NAME_INVOICE = "invoice";
@SerializedName(SERIALIZED_NAME_INVOICE)
private PreviewSubscriptionInvoice invoice;
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_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_CONTRACTED_VALUE = "totalContractedValue";
@SerializedName(SERIALIZED_NAME_TOTAL_CONTRACTED_VALUE)
private BigDecimal totalContractedValue;
public PreviewSubscriptionResponse() {
}
@Deprecated
public PreviewSubscriptionResponse amount(BigDecimal amount) {
this.amount = amount;
return this;
}
/**
* Invoice amount. 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 PreviewSubscriptionResponse amountWithoutTax(BigDecimal amountWithoutTax) {
this.amountWithoutTax = amountWithoutTax;
return this;
}
/**
* Invoice amount minus tax. 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 PreviewSubscriptionResponse chargeMetrics(List chargeMetrics) {
this.chargeMetrics = chargeMetrics;
return this;
}
public PreviewSubscriptionResponse addChargeMetricsItem(ChargeMetrics chargeMetricsItem) {
if (this.chargeMetrics == null) {
this.chargeMetrics = new ArrayList<>();
}
this.chargeMetrics.add(chargeMetricsItem);
return this;
}
/**
* Get chargeMetrics
* @return chargeMetrics
*/
@javax.annotation.Nullable
public List getChargeMetrics() {
return chargeMetrics;
}
public void setChargeMetrics(List chargeMetrics) {
this.chargeMetrics = chargeMetrics;
}
public PreviewSubscriptionResponse contractedMrr(BigDecimal contractedMrr) {
this.contractedMrr = contractedMrr;
return this;
}
/**
* Monthly recurring revenue of the subscription.
* @return contractedMrr
*/
@javax.annotation.Nullable
public BigDecimal getContractedMrr() {
return contractedMrr;
}
public void setContractedMrr(BigDecimal contractedMrr) {
this.contractedMrr = contractedMrr;
}
public PreviewSubscriptionResponse 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 PreviewSubscriptionResponse documentDate(LocalDate documentDate) {
this.documentDate = documentDate;
return this;
}
/**
* The date of the billing document, in `yyyy-mm-dd` format. It represents the invoice date for invoices, credit memo date for credit memos, and debit memo date for debit memos. - If this field is specified, the specified date is used as the billing document date. - If this field is not specified, the date specified in the `targetDate` is used as the billing document date.
* @return documentDate
*/
@javax.annotation.Nullable
public LocalDate getDocumentDate() {
return documentDate;
}
public void setDocumentDate(LocalDate documentDate) {
this.documentDate = documentDate;
}
public PreviewSubscriptionResponse 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;
}
@Deprecated
public PreviewSubscriptionResponse invoiceItems(List invoiceItems) {
this.invoiceItems = invoiceItems;
return this;
}
public PreviewSubscriptionResponse addInvoiceItemsItem(PreviewSubscriptionInvoiceItem invoiceItemsItem) {
if (this.invoiceItems == null) {
this.invoiceItems = new ArrayList<>();
}
this.invoiceItems.add(invoiceItemsItem);
return this;
}
/**
* Container for invoice items. 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 invoiceItems
* @deprecated
*/
@Deprecated
@javax.annotation.Nullable
public List getInvoiceItems() {
return invoiceItems;
}
@Deprecated
public void setInvoiceItems(List invoiceItems) {
this.invoiceItems = invoiceItems;
}
@Deprecated
public PreviewSubscriptionResponse invoiceTargetDate(LocalDate invoiceTargetDate) {
this.invoiceTargetDate = invoiceTargetDate;
return this;
}
/**
* Date through which charges are calculated on the invoice, as yyyy-mm-dd. **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, 196.0, and 206.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 PreviewSubscriptionResponse 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 PreviewSubscriptionResponse 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 PreviewSubscriptionResponse 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 PreviewSubscriptionResponse totalContractedValue(BigDecimal totalContractedValue) {
this.totalContractedValue = totalContractedValue;
return this;
}
/**
* Total contracted value of the subscription.
* @return totalContractedValue
*/
@javax.annotation.Nullable
public BigDecimal getTotalContractedValue() {
return totalContractedValue;
}
public void setTotalContractedValue(BigDecimal totalContractedValue) {
this.totalContractedValue = totalContractedValue;
}
/**
* 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 PreviewSubscriptionResponse instance itself
*/
public PreviewSubscriptionResponse 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;
}
PreviewSubscriptionResponse previewSubscriptionResponse = (PreviewSubscriptionResponse) o;
return Objects.equals(this.amount, previewSubscriptionResponse.amount) &&
Objects.equals(this.amountWithoutTax, previewSubscriptionResponse.amountWithoutTax) &&
Objects.equals(this.chargeMetrics, previewSubscriptionResponse.chargeMetrics) &&
Objects.equals(this.contractedMrr, previewSubscriptionResponse.contractedMrr) &&
Objects.equals(this.creditMemo, previewSubscriptionResponse.creditMemo) &&
Objects.equals(this.documentDate, previewSubscriptionResponse.documentDate) &&
Objects.equals(this.invoice, previewSubscriptionResponse.invoice) &&
Objects.equals(this.invoiceItems, previewSubscriptionResponse.invoiceItems) &&
Objects.equals(this.invoiceTargetDate, previewSubscriptionResponse.invoiceTargetDate) &&
Objects.equals(this.success, previewSubscriptionResponse.success) &&
Objects.equals(this.targetDate, previewSubscriptionResponse.targetDate) &&
Objects.equals(this.taxAmount, previewSubscriptionResponse.taxAmount) &&
Objects.equals(this.totalContractedValue, previewSubscriptionResponse.totalContractedValue)&&
Objects.equals(this.additionalProperties, previewSubscriptionResponse.additionalProperties);
}
@Override
public int hashCode() {
return Objects.hash(amount, amountWithoutTax, chargeMetrics, contractedMrr, creditMemo, documentDate, invoice, invoiceItems, invoiceTargetDate, success, targetDate, taxAmount, totalContractedValue, additionalProperties);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class PreviewSubscriptionResponse {\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(" contractedMrr: ").append(toIndentedString(contractedMrr)).append("\n");
sb.append(" creditMemo: ").append(toIndentedString(creditMemo)).append("\n");
sb.append(" documentDate: ").append(toIndentedString(documentDate)).append("\n");
sb.append(" invoice: ").append(toIndentedString(invoice)).append("\n");
sb.append(" invoiceItems: ").append(toIndentedString(invoiceItems)).append("\n");
sb.append(" invoiceTargetDate: ").append(toIndentedString(invoiceTargetDate)).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(" totalContractedValue: ").append(toIndentedString(totalContractedValue)).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("contractedMrr");
openapiFields.add("creditMemo");
openapiFields.add("documentDate");
openapiFields.add("invoice");
openapiFields.add("invoiceItems");
openapiFields.add("invoiceTargetDate");
openapiFields.add("success");
openapiFields.add("targetDate");
openapiFields.add("taxAmount");
openapiFields.add("totalContractedValue");
// 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 PreviewSubscriptionResponse
*/
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
if (jsonElement == null) {
if (!PreviewSubscriptionResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in PreviewSubscriptionResponse is not found in the empty JSON string", PreviewSubscriptionResponse.openapiRequiredFields.toString()));
}
}
JsonObject jsonObj = jsonElement.getAsJsonObject();
if (jsonObj.get("chargeMetrics") != null && !jsonObj.get("chargeMetrics").isJsonNull()) {
JsonArray jsonArraychargeMetrics = jsonObj.getAsJsonArray("chargeMetrics");
if (jsonArraychargeMetrics != null) {
// ensure the json data is an array
if (!jsonObj.get("chargeMetrics").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `chargeMetrics` to be an array in the JSON string but got `%s`", jsonObj.get("chargeMetrics").toString()));
}
// validate the optional field `chargeMetrics` (array)
for (int i = 0; i < jsonArraychargeMetrics.size(); i++) {
ChargeMetrics.validateJsonElement(jsonArraychargeMetrics.get(i));
};
}
}
// validate the optional field `creditMemo`
if (jsonObj.get("creditMemo") != null && !jsonObj.get("creditMemo").isJsonNull()) {
SubscriptionCreditMemo.validateJsonElement(jsonObj.get("creditMemo"));
}
// validate the optional field `invoice`
if (jsonObj.get("invoice") != null && !jsonObj.get("invoice").isJsonNull()) {
PreviewSubscriptionInvoice.validateJsonElement(jsonObj.get("invoice"));
}
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));
};
}
}
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@SuppressWarnings("unchecked")
@Override
public TypeAdapter create(Gson gson, TypeToken type) {
if (!PreviewSubscriptionResponse.class.isAssignableFrom(type.getRawType())) {
return null; // this class only serializes 'PreviewSubscriptionResponse' and its subtypes
}
final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
final TypeAdapter thisAdapter
= gson.getDelegateAdapter(this, TypeToken.get(PreviewSubscriptionResponse.class));
return (TypeAdapter) new TypeAdapter() {
@Override
public void write(JsonWriter out, PreviewSubscriptionResponse 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 PreviewSubscriptionResponse read(JsonReader in) throws IOException {
JsonElement jsonElement = elementAdapter.read(in);
validateJsonElement(jsonElement);
JsonObject jsonObj = jsonElement.getAsJsonObject();
// store additional fields in the deserialized instance
PreviewSubscriptionResponse 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 PreviewSubscriptionResponse given an JSON string
*
* @param jsonString JSON string
* @return An instance of PreviewSubscriptionResponse
* @throws IOException if the JSON string is invalid with respect to PreviewSubscriptionResponse
*/
public static PreviewSubscriptionResponse fromJson(String jsonString) throws IOException {
return JSON.getGson().fromJson(jsonString, PreviewSubscriptionResponse.class);
}
/**
* Convert an instance of PreviewSubscriptionResponse to an JSON string
*
* @return JSON string
*/
public String toJson() {
return JSON.getGson().toJson(this);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy