com.cashfree.pg.model.CFRefund Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of api Show documentation
Show all versions of api Show documentation
Cashfree Payments, PG Java SDK
/*
* New Payment Gateway APIs
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 2022-01-01
* 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.cashfree.pg.model;
import com.cashfree.pg.JSON;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.TypeAdapter;
import com.google.gson.TypeAdapterFactory;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.annotations.SerializedName;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
/** CFRefund */
@javax.annotation.Generated(
value = "org.openapitools.codegen.languages.JavaClientCodegen",
date = "2023-03-16T14:01:52.135917+05:30[Asia/Kolkata]")
public class CFRefund {
public static final String SERIALIZED_NAME_CF_PAYMENT_ID = "cf_payment_id";
@SerializedName(SERIALIZED_NAME_CF_PAYMENT_ID)
private Integer cfPaymentId;
public static final String SERIALIZED_NAME_CF_REFUND_ID = "cf_refund_id";
@SerializedName(SERIALIZED_NAME_CF_REFUND_ID)
private String cfRefundId;
public static final String SERIALIZED_NAME_ORDER_ID = "order_id";
@SerializedName(SERIALIZED_NAME_ORDER_ID)
private String orderId;
public static final String SERIALIZED_NAME_REFUND_ID = "refund_id";
@SerializedName(SERIALIZED_NAME_REFUND_ID)
private String refundId;
/** Type of object */
@JsonAdapter(EntityEnum.Adapter.class)
public enum EntityEnum {
REFUND("refund");
private String value;
EntityEnum(String value) {
this.value = value;
}
public String getValue() {
return value;
}
@Override
public String toString() {
return String.valueOf(value);
}
public static EntityEnum fromValue(String value) {
for (EntityEnum b : EntityEnum.values()) {
if (b.value.equals(value)) {
return b;
}
}
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
public static class Adapter extends TypeAdapter {
@Override
public void write(final JsonWriter jsonWriter, final EntityEnum enumeration)
throws IOException {
jsonWriter.value(enumeration.getValue());
}
@Override
public EntityEnum read(final JsonReader jsonReader) throws IOException {
String value = jsonReader.nextString();
return EntityEnum.fromValue(value);
}
}
}
public static final String SERIALIZED_NAME_ENTITY = "entity";
@SerializedName(SERIALIZED_NAME_ENTITY)
private EntityEnum entity;
public static final String SERIALIZED_NAME_REFUND_AMOUNT = "refund_amount";
@SerializedName(SERIALIZED_NAME_REFUND_AMOUNT)
private BigDecimal refundAmount;
public static final String SERIALIZED_NAME_REFUND_CURRENCY = "refund_currency";
@SerializedName(SERIALIZED_NAME_REFUND_CURRENCY)
private String refundCurrency;
public static final String SERIALIZED_NAME_REFUND_NOTE = "refund_note";
@SerializedName(SERIALIZED_NAME_REFUND_NOTE)
private String refundNote;
/**
* This can be one of [\"SUCCESS\", \"PENDING\", \"CANCELLED\",
* \"ONHOLD\"]
*/
@JsonAdapter(RefundStatusEnum.Adapter.class)
public enum RefundStatusEnum {
SUCCESS("SUCCESS"),
PENDING("PENDING"),
CANCELLED("CANCELLED"),
ONHOLD("ONHOLD");
private String value;
RefundStatusEnum(String value) {
this.value = value;
}
public String getValue() {
return value;
}
@Override
public String toString() {
return String.valueOf(value);
}
public static RefundStatusEnum fromValue(String value) {
for (RefundStatusEnum b : RefundStatusEnum.values()) {
if (b.value.equals(value)) {
return b;
}
}
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
public static class Adapter extends TypeAdapter {
@Override
public void write(final JsonWriter jsonWriter, final RefundStatusEnum enumeration)
throws IOException {
jsonWriter.value(enumeration.getValue());
}
@Override
public RefundStatusEnum read(final JsonReader jsonReader) throws IOException {
String value = jsonReader.nextString();
return RefundStatusEnum.fromValue(value);
}
}
}
public static final String SERIALIZED_NAME_REFUND_STATUS = "refund_status";
@SerializedName(SERIALIZED_NAME_REFUND_STATUS)
private RefundStatusEnum refundStatus;
public static final String SERIALIZED_NAME_REFUND_ARN = "refund_arn";
@SerializedName(SERIALIZED_NAME_REFUND_ARN)
private String refundArn;
public static final String SERIALIZED_NAME_REFUND_CHARGE = "refund_charge";
@SerializedName(SERIALIZED_NAME_REFUND_CHARGE)
private BigDecimal refundCharge;
public static final String SERIALIZED_NAME_STATUS_DESCRIPTION = "status_description";
@SerializedName(SERIALIZED_NAME_STATUS_DESCRIPTION)
private String statusDescription;
public static final String SERIALIZED_NAME_METADATA = "metadata";
@SerializedName(SERIALIZED_NAME_METADATA)
private Object metadata;
public static final String SERIALIZED_NAME_REFUND_SPLITS = "refund_splits";
@SerializedName(SERIALIZED_NAME_REFUND_SPLITS)
private List refundSplits = new ArrayList<>();
/**
* This can be one of [\"PAYMENT_AUTO_REFUND\", \"MERCHANT_INITIATED\",
* \"UNRECONCILED_AUTO_REFUND\"]
*/
@JsonAdapter(RefundTypeEnum.Adapter.class)
public enum RefundTypeEnum {
PAYMENT_AUTO_REFUND("PAYMENT_AUTO_REFUND"),
MERCHANT_INITIATED("MERCHANT_INITIATED"),
UNRECONCILED_AUTO_REFUND("UNRECONCILED_AUTO_REFUND");
private String value;
RefundTypeEnum(String value) {
this.value = value;
}
public String getValue() {
return value;
}
@Override
public String toString() {
return String.valueOf(value);
}
public static RefundTypeEnum fromValue(String value) {
for (RefundTypeEnum b : RefundTypeEnum.values()) {
if (b.value.equals(value)) {
return b;
}
}
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
public static class Adapter extends TypeAdapter {
@Override
public void write(final JsonWriter jsonWriter, final RefundTypeEnum enumeration)
throws IOException {
jsonWriter.value(enumeration.getValue());
}
@Override
public RefundTypeEnum read(final JsonReader jsonReader) throws IOException {
String value = jsonReader.nextString();
return RefundTypeEnum.fromValue(value);
}
}
}
public static final String SERIALIZED_NAME_REFUND_TYPE = "refund_type";
@SerializedName(SERIALIZED_NAME_REFUND_TYPE)
private RefundTypeEnum refundType;
/** Method or speed of processing refund */
@JsonAdapter(RefundModeEnum.Adapter.class)
public enum RefundModeEnum {
STANDARD("STANDARD"),
INSTANT("INSTANT");
private String value;
RefundModeEnum(String value) {
this.value = value;
}
public String getValue() {
return value;
}
@Override
public String toString() {
return String.valueOf(value);
}
public static RefundModeEnum fromValue(String value) {
for (RefundModeEnum b : RefundModeEnum.values()) {
if (b.value.equals(value)) {
return b;
}
}
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
public static class Adapter extends TypeAdapter {
@Override
public void write(final JsonWriter jsonWriter, final RefundModeEnum enumeration)
throws IOException {
jsonWriter.value(enumeration.getValue());
}
@Override
public RefundModeEnum read(final JsonReader jsonReader) throws IOException {
String value = jsonReader.nextString();
return RefundModeEnum.fromValue(value);
}
}
}
public static final String SERIALIZED_NAME_REFUND_MODE = "refund_mode";
@SerializedName(SERIALIZED_NAME_REFUND_MODE)
private RefundModeEnum refundMode;
public static final String SERIALIZED_NAME_CREATED_AT = "created_at";
@SerializedName(SERIALIZED_NAME_CREATED_AT)
private String createdAt;
public static final String SERIALIZED_NAME_PROCESSED_AT = "processed_at";
@SerializedName(SERIALIZED_NAME_PROCESSED_AT)
private String processedAt;
public static final String SERIALIZED_NAME_REFUND_SPEED = "refund_speed";
@SerializedName(SERIALIZED_NAME_REFUND_SPEED)
private RefundSpeed refundSpeed;
public CFRefund() {}
public CFRefund cfPaymentId(Integer cfPaymentId) {
this.cfPaymentId = cfPaymentId;
return this;
}
/**
* Cashfree Payments ID of the payment for which refund is initiated
*
* @return cfPaymentId
*/
@javax.annotation.Nullable
public Integer getCfPaymentId() {
return cfPaymentId;
}
public void setCfPaymentId(Integer cfPaymentId) {
this.cfPaymentId = cfPaymentId;
}
public CFRefund cfRefundId(String cfRefundId) {
this.cfRefundId = cfRefundId;
return this;
}
/**
* Cashfree Payments ID for a refund
*
* @return cfRefundId
*/
@javax.annotation.Nullable
public String getCfRefundId() {
return cfRefundId;
}
public void setCfRefundId(String cfRefundId) {
this.cfRefundId = cfRefundId;
}
public CFRefund orderId(String orderId) {
this.orderId = orderId;
return this;
}
/**
* Merchant's order Id of the order for which refund is initiated
*
* @return orderId
*/
@javax.annotation.Nullable
public String getOrderId() {
return orderId;
}
public void setOrderId(String orderId) {
this.orderId = orderId;
}
public CFRefund refundId(String refundId) {
this.refundId = refundId;
return this;
}
/**
* Merchant's refund ID of the refund
*
* @return refundId
*/
@javax.annotation.Nullable
public String getRefundId() {
return refundId;
}
public void setRefundId(String refundId) {
this.refundId = refundId;
}
public CFRefund entity(EntityEnum entity) {
this.entity = entity;
return this;
}
/**
* Type of object
*
* @return entity
*/
@javax.annotation.Nullable
public EntityEnum getEntity() {
return entity;
}
public void setEntity(EntityEnum entity) {
this.entity = entity;
}
public CFRefund refundAmount(BigDecimal refundAmount) {
this.refundAmount = refundAmount;
return this;
}
/**
* Amount that is refunded
*
* @return refundAmount
*/
@javax.annotation.Nullable
public BigDecimal getRefundAmount() {
return refundAmount;
}
public void setRefundAmount(BigDecimal refundAmount) {
this.refundAmount = refundAmount;
}
public CFRefund refundCurrency(String refundCurrency) {
this.refundCurrency = refundCurrency;
return this;
}
/**
* Currency of the refund amount
*
* @return refundCurrency
*/
@javax.annotation.Nullable
public String getRefundCurrency() {
return refundCurrency;
}
public void setRefundCurrency(String refundCurrency) {
this.refundCurrency = refundCurrency;
}
public CFRefund refundNote(String refundNote) {
this.refundNote = refundNote;
return this;
}
/**
* Note added by merchant for the refund
*
* @return refundNote
*/
@javax.annotation.Nullable
public String getRefundNote() {
return refundNote;
}
public void setRefundNote(String refundNote) {
this.refundNote = refundNote;
}
public CFRefund refundStatus(RefundStatusEnum refundStatus) {
this.refundStatus = refundStatus;
return this;
}
/**
* This can be one of [\"SUCCESS\", \"PENDING\", \"CANCELLED\",
* \"ONHOLD\"]
*
* @return refundStatus
*/
@javax.annotation.Nullable
public RefundStatusEnum getRefundStatus() {
return refundStatus;
}
public void setRefundStatus(RefundStatusEnum refundStatus) {
this.refundStatus = refundStatus;
}
public CFRefund refundArn(String refundArn) {
this.refundArn = refundArn;
return this;
}
/**
* The bank reference number for refund
*
* @return refundArn
*/
@javax.annotation.Nullable
public String getRefundArn() {
return refundArn;
}
public void setRefundArn(String refundArn) {
this.refundArn = refundArn;
}
public CFRefund refundCharge(BigDecimal refundCharge) {
this.refundCharge = refundCharge;
return this;
}
/**
* Charges in INR for processing refund
*
* @return refundCharge
*/
@javax.annotation.Nullable
public BigDecimal getRefundCharge() {
return refundCharge;
}
public void setRefundCharge(BigDecimal refundCharge) {
this.refundCharge = refundCharge;
}
public CFRefund statusDescription(String statusDescription) {
this.statusDescription = statusDescription;
return this;
}
/**
* Description of refund status
*
* @return statusDescription
*/
@javax.annotation.Nullable
public String getStatusDescription() {
return statusDescription;
}
public void setStatusDescription(String statusDescription) {
this.statusDescription = statusDescription;
}
public CFRefund metadata(Object metadata) {
this.metadata = metadata;
return this;
}
/**
* Key-value pair that can be used to store additional information about the entity. Maximum 5
* key-value pairs
*
* @return metadata
*/
@javax.annotation.Nullable
public Object getMetadata() {
return metadata;
}
public void setMetadata(Object metadata) {
this.metadata = metadata;
}
public CFRefund refundSplits(List refundSplits) {
this.refundSplits = refundSplits;
return this;
}
public CFRefund addRefundSplitsItem(CFVendorSplit refundSplitsItem) {
if (this.refundSplits == null) {
this.refundSplits = new ArrayList<>();
}
this.refundSplits.add(refundSplitsItem);
return this;
}
/**
* Get refundSplits
*
* @return refundSplits
*/
@javax.annotation.Nullable
public List getRefundSplits() {
return refundSplits;
}
public void setRefundSplits(List refundSplits) {
this.refundSplits = refundSplits;
}
public CFRefund refundType(RefundTypeEnum refundType) {
this.refundType = refundType;
return this;
}
/**
* This can be one of [\"PAYMENT_AUTO_REFUND\", \"MERCHANT_INITIATED\",
* \"UNRECONCILED_AUTO_REFUND\"]
*
* @return refundType
*/
@javax.annotation.Nullable
public RefundTypeEnum getRefundType() {
return refundType;
}
public void setRefundType(RefundTypeEnum refundType) {
this.refundType = refundType;
}
public CFRefund refundMode(RefundModeEnum refundMode) {
this.refundMode = refundMode;
return this;
}
/**
* Method or speed of processing refund
*
* @return refundMode
*/
@javax.annotation.Nullable
public RefundModeEnum getRefundMode() {
return refundMode;
}
public void setRefundMode(RefundModeEnum refundMode) {
this.refundMode = refundMode;
}
public CFRefund createdAt(String createdAt) {
this.createdAt = createdAt;
return this;
}
/**
* Time of refund creation
*
* @return createdAt
*/
@javax.annotation.Nullable
public String getCreatedAt() {
return createdAt;
}
public void setCreatedAt(String createdAt) {
this.createdAt = createdAt;
}
public CFRefund processedAt(String processedAt) {
this.processedAt = processedAt;
return this;
}
/**
* Time when refund was processed successfully
*
* @return processedAt
*/
@javax.annotation.Nullable
public String getProcessedAt() {
return processedAt;
}
public void setProcessedAt(String processedAt) {
this.processedAt = processedAt;
}
public CFRefund refundSpeed(RefundSpeed refundSpeed) {
this.refundSpeed = refundSpeed;
return this;
}
/**
* Get refundSpeed
*
* @return refundSpeed
*/
@javax.annotation.Nullable
public RefundSpeed getRefundSpeed() {
return refundSpeed;
}
public void setRefundSpeed(RefundSpeed refundSpeed) {
this.refundSpeed = refundSpeed;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
CFRefund cfRefund = (CFRefund) o;
return Objects.equals(this.cfPaymentId, cfRefund.cfPaymentId)
&& Objects.equals(this.cfRefundId, cfRefund.cfRefundId)
&& Objects.equals(this.orderId, cfRefund.orderId)
&& Objects.equals(this.refundId, cfRefund.refundId)
&& Objects.equals(this.entity, cfRefund.entity)
&& Objects.equals(this.refundAmount, cfRefund.refundAmount)
&& Objects.equals(this.refundCurrency, cfRefund.refundCurrency)
&& Objects.equals(this.refundNote, cfRefund.refundNote)
&& Objects.equals(this.refundStatus, cfRefund.refundStatus)
&& Objects.equals(this.refundArn, cfRefund.refundArn)
&& Objects.equals(this.refundCharge, cfRefund.refundCharge)
&& Objects.equals(this.statusDescription, cfRefund.statusDescription)
&& Objects.equals(this.metadata, cfRefund.metadata)
&& Objects.equals(this.refundSplits, cfRefund.refundSplits)
&& Objects.equals(this.refundType, cfRefund.refundType)
&& Objects.equals(this.refundMode, cfRefund.refundMode)
&& Objects.equals(this.createdAt, cfRefund.createdAt)
&& Objects.equals(this.processedAt, cfRefund.processedAt)
&& Objects.equals(this.refundSpeed, cfRefund.refundSpeed);
}
@Override
public int hashCode() {
return Objects.hash(
cfPaymentId,
cfRefundId,
orderId,
refundId,
entity,
refundAmount,
refundCurrency,
refundNote,
refundStatus,
refundArn,
refundCharge,
statusDescription,
metadata,
refundSplits,
refundType,
refundMode,
createdAt,
processedAt,
refundSpeed);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class CFRefund {\n");
sb.append(" cfPaymentId: ").append(toIndentedString(cfPaymentId)).append("\n");
sb.append(" cfRefundId: ").append(toIndentedString(cfRefundId)).append("\n");
sb.append(" orderId: ").append(toIndentedString(orderId)).append("\n");
sb.append(" refundId: ").append(toIndentedString(refundId)).append("\n");
sb.append(" entity: ").append(toIndentedString(entity)).append("\n");
sb.append(" refundAmount: ").append(toIndentedString(refundAmount)).append("\n");
sb.append(" refundCurrency: ").append(toIndentedString(refundCurrency)).append("\n");
sb.append(" refundNote: ").append(toIndentedString(refundNote)).append("\n");
sb.append(" refundStatus: ").append(toIndentedString(refundStatus)).append("\n");
sb.append(" refundArn: ").append(toIndentedString(refundArn)).append("\n");
sb.append(" refundCharge: ").append(toIndentedString(refundCharge)).append("\n");
sb.append(" statusDescription: ")
.append(toIndentedString(statusDescription))
.append("\n");
sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n");
sb.append(" refundSplits: ").append(toIndentedString(refundSplits)).append("\n");
sb.append(" refundType: ").append(toIndentedString(refundType)).append("\n");
sb.append(" refundMode: ").append(toIndentedString(refundMode)).append("\n");
sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n");
sb.append(" processedAt: ").append(toIndentedString(processedAt)).append("\n");
sb.append(" refundSpeed: ").append(toIndentedString(refundSpeed)).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("cf_payment_id");
openapiFields.add("cf_refund_id");
openapiFields.add("order_id");
openapiFields.add("refund_id");
openapiFields.add("entity");
openapiFields.add("refund_amount");
openapiFields.add("refund_currency");
openapiFields.add("refund_note");
openapiFields.add("refund_status");
openapiFields.add("refund_arn");
openapiFields.add("refund_charge");
openapiFields.add("status_description");
openapiFields.add("metadata");
openapiFields.add("refund_splits");
openapiFields.add("refund_type");
openapiFields.add("refund_mode");
openapiFields.add("created_at");
openapiFields.add("processed_at");
openapiFields.add("refund_speed");
// a set of required properties/fields (JSON key names)
openapiRequiredFields = new HashSet();
}
/**
* Validates the JSON Object and throws an exception if issues found
*
* @param jsonObj JSON Object
* @throws IOException if the JSON Object is invalid with respect to CFRefund
*/
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
if (jsonObj == null) {
if (!CFRefund.openapiRequiredFields
.isEmpty()) { // has required fields but JSON object is null
throw new IllegalArgumentException(
String.format(
"The required field(s) %s in CFRefund is not found in the empty"
+ " JSON string",
CFRefund.openapiRequiredFields.toString()));
}
}
Set> entries = jsonObj.entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!CFRefund.openapiFields.contains(entry.getKey())) {
throw new IllegalArgumentException(
String.format(
"The field `%s` in the JSON string is not defined in the"
+ " `CFRefund` properties. JSON: %s",
entry.getKey(), jsonObj.toString()));
}
}
if ((jsonObj.get("cf_refund_id") != null && !jsonObj.get("cf_refund_id").isJsonNull())
&& !jsonObj.get("cf_refund_id").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
"Expected the field `cf_refund_id` to be a primitive type in the JSON"
+ " string but got `%s`",
jsonObj.get("cf_refund_id").toString()));
}
if ((jsonObj.get("order_id") != null && !jsonObj.get("order_id").isJsonNull())
&& !jsonObj.get("order_id").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
"Expected the field `order_id` to be a primitive type in the JSON"
+ " string but got `%s`",
jsonObj.get("order_id").toString()));
}
if ((jsonObj.get("refund_id") != null && !jsonObj.get("refund_id").isJsonNull())
&& !jsonObj.get("refund_id").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
"Expected the field `refund_id` to be a primitive type in the JSON"
+ " string but got `%s`",
jsonObj.get("refund_id").toString()));
}
if ((jsonObj.get("entity") != null && !jsonObj.get("entity").isJsonNull())
&& !jsonObj.get("entity").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
"Expected the field `entity` to be a primitive type in the JSON string"
+ " but got `%s`",
jsonObj.get("entity").toString()));
}
if ((jsonObj.get("refund_currency") != null && !jsonObj.get("refund_currency").isJsonNull())
&& !jsonObj.get("refund_currency").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
"Expected the field `refund_currency` to be a primitive type in the"
+ " JSON string but got `%s`",
jsonObj.get("refund_currency").toString()));
}
if ((jsonObj.get("refund_note") != null && !jsonObj.get("refund_note").isJsonNull())
&& !jsonObj.get("refund_note").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
"Expected the field `refund_note` to be a primitive type in the JSON"
+ " string but got `%s`",
jsonObj.get("refund_note").toString()));
}
if ((jsonObj.get("refund_status") != null && !jsonObj.get("refund_status").isJsonNull())
&& !jsonObj.get("refund_status").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
"Expected the field `refund_status` to be a primitive type in the JSON"
+ " string but got `%s`",
jsonObj.get("refund_status").toString()));
}
if ((jsonObj.get("refund_arn") != null && !jsonObj.get("refund_arn").isJsonNull())
&& !jsonObj.get("refund_arn").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
"Expected the field `refund_arn` to be a primitive type in the JSON"
+ " string but got `%s`",
jsonObj.get("refund_arn").toString()));
}
if ((jsonObj.get("status_description") != null
&& !jsonObj.get("status_description").isJsonNull())
&& !jsonObj.get("status_description").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
"Expected the field `status_description` to be a primitive type in the"
+ " JSON string but got `%s`",
jsonObj.get("status_description").toString()));
}
if (jsonObj.get("refund_splits") != null && !jsonObj.get("refund_splits").isJsonNull()) {
JsonArray jsonArrayrefundSplits = jsonObj.getAsJsonArray("refund_splits");
if (jsonArrayrefundSplits != null) {
// ensure the json data is an array
if (!jsonObj.get("refund_splits").isJsonArray()) {
throw new IllegalArgumentException(
String.format(
"Expected the field `refund_splits` to be an array in the JSON"
+ " string but got `%s`",
jsonObj.get("refund_splits").toString()));
}
// validate the optional field `refund_splits` (array)
for (int i = 0; i < jsonArrayrefundSplits.size(); i++) {
CFVendorSplit.validateJsonObject(
jsonArrayrefundSplits.get(i).getAsJsonObject());
}
;
}
}
if ((jsonObj.get("refund_type") != null && !jsonObj.get("refund_type").isJsonNull())
&& !jsonObj.get("refund_type").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
"Expected the field `refund_type` to be a primitive type in the JSON"
+ " string but got `%s`",
jsonObj.get("refund_type").toString()));
}
if ((jsonObj.get("refund_mode") != null && !jsonObj.get("refund_mode").isJsonNull())
&& !jsonObj.get("refund_mode").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
"Expected the field `refund_mode` to be a primitive type in the JSON"
+ " string but got `%s`",
jsonObj.get("refund_mode").toString()));
}
if ((jsonObj.get("created_at") != null && !jsonObj.get("created_at").isJsonNull())
&& !jsonObj.get("created_at").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
"Expected the field `created_at` to be a primitive type in the JSON"
+ " string but got `%s`",
jsonObj.get("created_at").toString()));
}
if ((jsonObj.get("processed_at") != null && !jsonObj.get("processed_at").isJsonNull())
&& !jsonObj.get("processed_at").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
"Expected the field `processed_at` to be a primitive type in the JSON"
+ " string but got `%s`",
jsonObj.get("processed_at").toString()));
}
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@SuppressWarnings("unchecked")
@Override
public TypeAdapter create(Gson gson, TypeToken type) {
if (!CFRefund.class.isAssignableFrom(type.getRawType())) {
return null; // this class only serializes 'CFRefund' and its subtypes
}
final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
final TypeAdapter thisAdapter =
gson.getDelegateAdapter(this, TypeToken.get(CFRefund.class));
return (TypeAdapter)
new TypeAdapter() {
@Override
public void write(JsonWriter out, CFRefund value) throws IOException {
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
elementAdapter.write(out, obj);
}
@Override
public CFRefund read(JsonReader in) throws IOException {
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
validateJsonObject(jsonObj);
return thisAdapter.fromJsonTree(jsonObj);
}
}.nullSafe();
}
}
/**
* Create an instance of CFRefund given an JSON string
*
* @param jsonString JSON string
* @return An instance of CFRefund
* @throws IOException if the JSON string is invalid with respect to CFRefund
*/
public static CFRefund fromJson(String jsonString) throws IOException {
return JSON.getGson().fromJson(jsonString, CFRefund.class);
}
/**
* Convert an instance of CFRefund to an JSON string
*
* @return JSON string
*/
public String toJson() {
return JSON.getGson().toJson(this);
}
}