com.zuora.model.CreateRefundwithAutoUnapply 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.ApplyPaymentDebitMemoApplication;
import com.zuora.model.ApplyPaymentInvoiceApplication;
import com.zuora.model.GatewayOptions;
import com.zuora.model.PaymentMethodType;
import com.zuora.model.RefundRequestFinanceInformation;
import com.zuora.model.RefundTransactionType;
import com.zuora.model.RefundType;
import java.io.IOException;
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;
/**
* CreateRefundwithAutoUnapply
*/
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.6.0")
public class CreateRefundwithAutoUnapply {
public static final String SERIALIZED_NAME_COMMENT = "comment";
@SerializedName(SERIALIZED_NAME_COMMENT)
private String comment;
public static final String SERIALIZED_NAME_DEBIT_MEMOS = "debitMemos";
@SerializedName(SERIALIZED_NAME_DEBIT_MEMOS)
private List debitMemos;
public static final String SERIALIZED_NAME_FINANCE_INFORMATION = "financeInformation";
@SerializedName(SERIALIZED_NAME_FINANCE_INFORMATION)
private RefundRequestFinanceInformation financeInformation;
public static final String SERIALIZED_NAME_GATEWAY_OPTIONS = "gatewayOptions";
@SerializedName(SERIALIZED_NAME_GATEWAY_OPTIONS)
private GatewayOptions gatewayOptions;
public static final String SERIALIZED_NAME_INVOICES = "invoices";
@SerializedName(SERIALIZED_NAME_INVOICES)
private List invoices;
public static final String SERIALIZED_NAME_METHOD_TYPE = "methodType";
@SerializedName(SERIALIZED_NAME_METHOD_TYPE)
private PaymentMethodType methodType;
public static final String SERIALIZED_NAME_REASON_CODE = "reasonCode";
@SerializedName(SERIALIZED_NAME_REASON_CODE)
private String reasonCode;
public static final String SERIALIZED_NAME_REFERENCE_ID = "referenceId";
@SerializedName(SERIALIZED_NAME_REFERENCE_ID)
private String referenceId;
public static final String SERIALIZED_NAME_REFUND_DATE = "refundDate";
@SerializedName(SERIALIZED_NAME_REFUND_DATE)
private LocalDate refundDate;
public static final String SERIALIZED_NAME_SECOND_REFUND_REFERENCE_ID = "secondRefundReferenceId";
@SerializedName(SERIALIZED_NAME_SECOND_REFUND_REFERENCE_ID)
private String secondRefundReferenceId;
public static final String SERIALIZED_NAME_SOFT_DESCRIPTOR = "softDescriptor";
@SerializedName(SERIALIZED_NAME_SOFT_DESCRIPTOR)
private String softDescriptor;
public static final String SERIALIZED_NAME_SOFT_DESCRIPTOR_PHONE = "softDescriptorPhone";
@SerializedName(SERIALIZED_NAME_SOFT_DESCRIPTOR_PHONE)
private String softDescriptorPhone;
public static final String SERIALIZED_NAME_TOTAL_AMOUNT = "totalAmount";
@SerializedName(SERIALIZED_NAME_TOTAL_AMOUNT)
private Double totalAmount;
public static final String SERIALIZED_NAME_TYPE = "type";
@SerializedName(SERIALIZED_NAME_TYPE)
private RefundType type;
public static final String SERIALIZED_NAME_REFUND_TRANSACTION_TYPE = "refundTransactionType";
@SerializedName(SERIALIZED_NAME_REFUND_TRANSACTION_TYPE)
private RefundTransactionType refundTransactionType;
public CreateRefundwithAutoUnapply() {
}
public CreateRefundwithAutoUnapply comment(String comment) {
this.comment = comment;
return this;
}
/**
* Comments about the refund.
* @return comment
*/
@javax.annotation.Nullable
public String getComment() {
return comment;
}
public void setComment(String comment) {
this.comment = comment;
}
public CreateRefundwithAutoUnapply debitMemos(List debitMemos) {
this.debitMemos = debitMemos;
return this;
}
public CreateRefundwithAutoUnapply addDebitMemosItem(ApplyPaymentDebitMemoApplication debitMemosItem) {
if (this.debitMemos == null) {
this.debitMemos = new ArrayList<>();
}
this.debitMemos.add(debitMemosItem);
return this;
}
/**
* Container for debit memos. The maximum number of debit memos is 1,000.
* @return debitMemos
*/
@javax.annotation.Nullable
public List getDebitMemos() {
return debitMemos;
}
public void setDebitMemos(List debitMemos) {
this.debitMemos = debitMemos;
}
public CreateRefundwithAutoUnapply financeInformation(RefundRequestFinanceInformation financeInformation) {
this.financeInformation = financeInformation;
return this;
}
/**
* Get financeInformation
* @return financeInformation
*/
@javax.annotation.Nullable
public RefundRequestFinanceInformation getFinanceInformation() {
return financeInformation;
}
public void setFinanceInformation(RefundRequestFinanceInformation financeInformation) {
this.financeInformation = financeInformation;
}
public CreateRefundwithAutoUnapply gatewayOptions(GatewayOptions gatewayOptions) {
this.gatewayOptions = gatewayOptions;
return this;
}
/**
* Get gatewayOptions
* @return gatewayOptions
*/
@javax.annotation.Nullable
public GatewayOptions getGatewayOptions() {
return gatewayOptions;
}
public void setGatewayOptions(GatewayOptions gatewayOptions) {
this.gatewayOptions = gatewayOptions;
}
public CreateRefundwithAutoUnapply invoices(List invoices) {
this.invoices = invoices;
return this;
}
public CreateRefundwithAutoUnapply addInvoicesItem(ApplyPaymentInvoiceApplication invoicesItem) {
if (this.invoices == null) {
this.invoices = new ArrayList<>();
}
this.invoices.add(invoicesItem);
return this;
}
/**
* Container for invoices. The maximum number of invoices is 1,000.
* @return invoices
*/
@javax.annotation.Nullable
public List getInvoices() {
return invoices;
}
public void setInvoices(List invoices) {
this.invoices = invoices;
}
public CreateRefundwithAutoUnapply methodType(PaymentMethodType methodType) {
this.methodType = methodType;
return this;
}
/**
* Get methodType
* @return methodType
*/
@javax.annotation.Nullable
public PaymentMethodType getMethodType() {
return methodType;
}
public void setMethodType(PaymentMethodType methodType) {
this.methodType = methodType;
}
public CreateRefundwithAutoUnapply reasonCode(String reasonCode) {
this.reasonCode = reasonCode;
return this;
}
/**
* A code identifying the reason for the transaction. The value must be an existing reason code or empty. If you do not specify a value, Zuora uses the default reason code.
* @return reasonCode
*/
@javax.annotation.Nullable
public String getReasonCode() {
return reasonCode;
}
public void setReasonCode(String reasonCode) {
this.reasonCode = reasonCode;
}
public CreateRefundwithAutoUnapply referenceId(String referenceId) {
this.referenceId = referenceId;
return this;
}
/**
* The transaction ID returned by the payment gateway for an electronic refund. Use this field to reconcile refunds between your gateway and Zuora Payments.
* @return referenceId
*/
@javax.annotation.Nullable
public String getReferenceId() {
return referenceId;
}
public void setReferenceId(String referenceId) {
this.referenceId = referenceId;
}
public CreateRefundwithAutoUnapply refundDate(LocalDate refundDate) {
this.refundDate = refundDate;
return this;
}
/**
* The date when the refund takes effect, in `yyyy-mm-dd` format. The date of the refund cannot be before the payment date. Specify this field only for external refunds. Zuora automatically generates this field for electronic refunds.
* @return refundDate
*/
@javax.annotation.Nullable
public LocalDate getRefundDate() {
return refundDate;
}
public void setRefundDate(LocalDate refundDate) {
this.refundDate = refundDate;
}
public CreateRefundwithAutoUnapply secondRefundReferenceId(String secondRefundReferenceId) {
this.secondRefundReferenceId = secondRefundReferenceId;
return this;
}
/**
* The transaction ID returned by the payment gateway if there is an additional transaction for the refund. Use this field to reconcile payments between your gateway and Zuora Payments.
* @return secondRefundReferenceId
*/
@javax.annotation.Nullable
public String getSecondRefundReferenceId() {
return secondRefundReferenceId;
}
public void setSecondRefundReferenceId(String secondRefundReferenceId) {
this.secondRefundReferenceId = secondRefundReferenceId;
}
public CreateRefundwithAutoUnapply softDescriptor(String softDescriptor) {
this.softDescriptor = softDescriptor;
return this;
}
/**
* A payment gateway-specific field that maps to Zuora for the gateways, Orbital, Vantiv and Verifi.
* @return softDescriptor
*/
@javax.annotation.Nullable
public String getSoftDescriptor() {
return softDescriptor;
}
public void setSoftDescriptor(String softDescriptor) {
this.softDescriptor = softDescriptor;
}
public CreateRefundwithAutoUnapply softDescriptorPhone(String softDescriptorPhone) {
this.softDescriptorPhone = softDescriptorPhone;
return this;
}
/**
* A payment gateway-specific field that maps to Zuora for the gateways, Orbital, Vantiv and Verifi.
* @return softDescriptorPhone
*/
@javax.annotation.Nullable
public String getSoftDescriptorPhone() {
return softDescriptorPhone;
}
public void setSoftDescriptorPhone(String softDescriptorPhone) {
this.softDescriptorPhone = softDescriptorPhone;
}
public CreateRefundwithAutoUnapply totalAmount(Double totalAmount) {
this.totalAmount = totalAmount;
return this;
}
/**
* The total amount of the refund. - `Full Refund`: If the refund amount and debit memo/ invoice are not specified, then the payment will be unapplied completely, followed by processing a full refund. - `Partial Refund`: - If the total amount is specified, and the debit memo/invoice is not specified, you can unapply the refund amount from the available debit memo/invoice and refund the unapplied payment to the customer. - If the total amount is specified, along with the debit memo and the invoice, you can unapply the applied payments from the mentioned invoices and debit memos, and refund the unapplied payments to customers.
* @return totalAmount
*/
@javax.annotation.Nonnull
public Double getTotalAmount() {
return totalAmount;
}
public void setTotalAmount(Double totalAmount) {
this.totalAmount = totalAmount;
}
public CreateRefundwithAutoUnapply type(RefundType type) {
this.type = type;
return this;
}
/**
* Get type
* @return type
*/
@javax.annotation.Nonnull
public RefundType getType() {
return type;
}
public void setType(RefundType type) {
this.type = type;
}
public CreateRefundwithAutoUnapply refundTransactionType(RefundTransactionType refundTransactionType) {
this.refundTransactionType = refundTransactionType;
return this;
}
/**
* Get refundTransactionType
* @return refundTransactionType
*/
@javax.annotation.Nullable
public RefundTransactionType getRefundTransactionType() {
return refundTransactionType;
}
public void setRefundTransactionType(RefundTransactionType refundTransactionType) {
this.refundTransactionType = refundTransactionType;
}
/**
* 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 CreateRefundwithAutoUnapply instance itself
*/
public CreateRefundwithAutoUnapply 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;
}
CreateRefundwithAutoUnapply createRefundwithAutoUnapply = (CreateRefundwithAutoUnapply) o;
return Objects.equals(this.comment, createRefundwithAutoUnapply.comment) &&
Objects.equals(this.debitMemos, createRefundwithAutoUnapply.debitMemos) &&
Objects.equals(this.financeInformation, createRefundwithAutoUnapply.financeInformation) &&
Objects.equals(this.gatewayOptions, createRefundwithAutoUnapply.gatewayOptions) &&
Objects.equals(this.invoices, createRefundwithAutoUnapply.invoices) &&
Objects.equals(this.methodType, createRefundwithAutoUnapply.methodType) &&
Objects.equals(this.reasonCode, createRefundwithAutoUnapply.reasonCode) &&
Objects.equals(this.referenceId, createRefundwithAutoUnapply.referenceId) &&
Objects.equals(this.refundDate, createRefundwithAutoUnapply.refundDate) &&
Objects.equals(this.secondRefundReferenceId, createRefundwithAutoUnapply.secondRefundReferenceId) &&
Objects.equals(this.softDescriptor, createRefundwithAutoUnapply.softDescriptor) &&
Objects.equals(this.softDescriptorPhone, createRefundwithAutoUnapply.softDescriptorPhone) &&
Objects.equals(this.totalAmount, createRefundwithAutoUnapply.totalAmount) &&
Objects.equals(this.type, createRefundwithAutoUnapply.type) &&
Objects.equals(this.refundTransactionType, createRefundwithAutoUnapply.refundTransactionType)&&
Objects.equals(this.additionalProperties, createRefundwithAutoUnapply.additionalProperties);
}
@Override
public int hashCode() {
return Objects.hash(comment, debitMemos, financeInformation, gatewayOptions, invoices, methodType, reasonCode, referenceId, refundDate, secondRefundReferenceId, softDescriptor, softDescriptorPhone, totalAmount, type, refundTransactionType, additionalProperties);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class CreateRefundwithAutoUnapply {\n");
sb.append(" comment: ").append(toIndentedString(comment)).append("\n");
sb.append(" debitMemos: ").append(toIndentedString(debitMemos)).append("\n");
sb.append(" financeInformation: ").append(toIndentedString(financeInformation)).append("\n");
sb.append(" gatewayOptions: ").append(toIndentedString(gatewayOptions)).append("\n");
sb.append(" invoices: ").append(toIndentedString(invoices)).append("\n");
sb.append(" methodType: ").append(toIndentedString(methodType)).append("\n");
sb.append(" reasonCode: ").append(toIndentedString(reasonCode)).append("\n");
sb.append(" referenceId: ").append(toIndentedString(referenceId)).append("\n");
sb.append(" refundDate: ").append(toIndentedString(refundDate)).append("\n");
sb.append(" secondRefundReferenceId: ").append(toIndentedString(secondRefundReferenceId)).append("\n");
sb.append(" softDescriptor: ").append(toIndentedString(softDescriptor)).append("\n");
sb.append(" softDescriptorPhone: ").append(toIndentedString(softDescriptorPhone)).append("\n");
sb.append(" totalAmount: ").append(toIndentedString(totalAmount)).append("\n");
sb.append(" type: ").append(toIndentedString(type)).append("\n");
sb.append(" refundTransactionType: ").append(toIndentedString(refundTransactionType)).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("comment");
openapiFields.add("debitMemos");
openapiFields.add("financeInformation");
openapiFields.add("gatewayOptions");
openapiFields.add("invoices");
openapiFields.add("methodType");
openapiFields.add("reasonCode");
openapiFields.add("referenceId");
openapiFields.add("refundDate");
openapiFields.add("secondRefundReferenceId");
openapiFields.add("softDescriptor");
openapiFields.add("softDescriptorPhone");
openapiFields.add("totalAmount");
openapiFields.add("type");
openapiFields.add("refundTransactionType");
// a set of required properties/fields (JSON key names)
openapiRequiredFields = new HashSet();
openapiRequiredFields.add("totalAmount");
openapiRequiredFields.add("type");
}
/**
* 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 CreateRefundwithAutoUnapply
*/
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
if (jsonElement == null) {
if (!CreateRefundwithAutoUnapply.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in CreateRefundwithAutoUnapply is not found in the empty JSON string", CreateRefundwithAutoUnapply.openapiRequiredFields.toString()));
}
}
// check to make sure all required properties/fields are present in the JSON string
for (String requiredField : CreateRefundwithAutoUnapply.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();
if ((jsonObj.get("comment") != null && !jsonObj.get("comment").isJsonNull()) && !jsonObj.get("comment").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `comment` to be a primitive type in the JSON string but got `%s`", jsonObj.get("comment").toString()));
}
if (jsonObj.get("debitMemos") != null && !jsonObj.get("debitMemos").isJsonNull()) {
JsonArray jsonArraydebitMemos = jsonObj.getAsJsonArray("debitMemos");
if (jsonArraydebitMemos != null) {
// ensure the json data is an array
if (!jsonObj.get("debitMemos").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `debitMemos` to be an array in the JSON string but got `%s`", jsonObj.get("debitMemos").toString()));
}
// validate the optional field `debitMemos` (array)
for (int i = 0; i < jsonArraydebitMemos.size(); i++) {
ApplyPaymentDebitMemoApplication.validateJsonElement(jsonArraydebitMemos.get(i));
};
}
}
// validate the optional field `financeInformation`
if (jsonObj.get("financeInformation") != null && !jsonObj.get("financeInformation").isJsonNull()) {
RefundRequestFinanceInformation.validateJsonElement(jsonObj.get("financeInformation"));
}
// validate the optional field `gatewayOptions`
if (jsonObj.get("gatewayOptions") != null && !jsonObj.get("gatewayOptions").isJsonNull()) {
GatewayOptions.validateJsonElement(jsonObj.get("gatewayOptions"));
}
if (jsonObj.get("invoices") != null && !jsonObj.get("invoices").isJsonNull()) {
JsonArray jsonArrayinvoices = jsonObj.getAsJsonArray("invoices");
if (jsonArrayinvoices != null) {
// ensure the json data is an array
if (!jsonObj.get("invoices").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `invoices` to be an array in the JSON string but got `%s`", jsonObj.get("invoices").toString()));
}
// validate the optional field `invoices` (array)
for (int i = 0; i < jsonArrayinvoices.size(); i++) {
ApplyPaymentInvoiceApplication.validateJsonElement(jsonArrayinvoices.get(i));
};
}
}
if ((jsonObj.get("methodType") != null && !jsonObj.get("methodType").isJsonNull()) && !jsonObj.get("methodType").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `methodType` to be a primitive type in the JSON string but got `%s`", jsonObj.get("methodType").toString()));
}
// validate the optional field `methodType`
if (jsonObj.get("methodType") != null && !jsonObj.get("methodType").isJsonNull()) {
PaymentMethodType.validateJsonElement(jsonObj.get("methodType"));
}
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("referenceId") != null && !jsonObj.get("referenceId").isJsonNull()) && !jsonObj.get("referenceId").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `referenceId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("referenceId").toString()));
}
if ((jsonObj.get("secondRefundReferenceId") != null && !jsonObj.get("secondRefundReferenceId").isJsonNull()) && !jsonObj.get("secondRefundReferenceId").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `secondRefundReferenceId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("secondRefundReferenceId").toString()));
}
if ((jsonObj.get("softDescriptor") != null && !jsonObj.get("softDescriptor").isJsonNull()) && !jsonObj.get("softDescriptor").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `softDescriptor` to be a primitive type in the JSON string but got `%s`", jsonObj.get("softDescriptor").toString()));
}
if ((jsonObj.get("softDescriptorPhone") != null && !jsonObj.get("softDescriptorPhone").isJsonNull()) && !jsonObj.get("softDescriptorPhone").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `softDescriptorPhone` to be a primitive type in the JSON string but got `%s`", jsonObj.get("softDescriptorPhone").toString()));
}
if (!jsonObj.get("type").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString()));
}
// validate the required field `type`
RefundType.validateJsonElement(jsonObj.get("type"));
if ((jsonObj.get("refundTransactionType") != null && !jsonObj.get("refundTransactionType").isJsonNull()) && !jsonObj.get("refundTransactionType").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `refundTransactionType` to be a primitive type in the JSON string but got `%s`", jsonObj.get("refundTransactionType").toString()));
}
// validate the optional field `refundTransactionType`
if (jsonObj.get("refundTransactionType") != null && !jsonObj.get("refundTransactionType").isJsonNull()) {
RefundTransactionType.validateJsonElement(jsonObj.get("refundTransactionType"));
}
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@SuppressWarnings("unchecked")
@Override
public TypeAdapter create(Gson gson, TypeToken type) {
if (!CreateRefundwithAutoUnapply.class.isAssignableFrom(type.getRawType())) {
return null; // this class only serializes 'CreateRefundwithAutoUnapply' and its subtypes
}
final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
final TypeAdapter thisAdapter
= gson.getDelegateAdapter(this, TypeToken.get(CreateRefundwithAutoUnapply.class));
return (TypeAdapter) new TypeAdapter() {
@Override
public void write(JsonWriter out, CreateRefundwithAutoUnapply 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 CreateRefundwithAutoUnapply read(JsonReader in) throws IOException {
JsonElement jsonElement = elementAdapter.read(in);
validateJsonElement(jsonElement);
JsonObject jsonObj = jsonElement.getAsJsonObject();
// store additional fields in the deserialized instance
CreateRefundwithAutoUnapply 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 CreateRefundwithAutoUnapply given an JSON string
*
* @param jsonString JSON string
* @return An instance of CreateRefundwithAutoUnapply
* @throws IOException if the JSON string is invalid with respect to CreateRefundwithAutoUnapply
*/
public static CreateRefundwithAutoUnapply fromJson(String jsonString) throws IOException {
return JSON.getGson().fromJson(jsonString, CreateRefundwithAutoUnapply.class);
}
/**
* Convert an instance of CreateRefundwithAutoUnapply to an JSON string
*
* @return JSON string
*/
public String toJson() {
return JSON.getGson().toJson(this);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy