com.cashfree.pg.model.CFFetchAllSavedInstruments 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.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.util.HashSet;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
/** CFFetchAllSavedInstruments */
@javax.annotation.Generated(
value = "org.openapitools.codegen.languages.JavaClientCodegen",
date = "2023-03-16T14:01:52.135917+05:30[Asia/Kolkata]")
public class CFFetchAllSavedInstruments {
public static final String SERIALIZED_NAME_CUSTOMER_ID = "customer_id";
@SerializedName(SERIALIZED_NAME_CUSTOMER_ID)
private String customerId;
public static final String SERIALIZED_NAME_AFA_REFERENCE = "afa_reference";
@SerializedName(SERIALIZED_NAME_AFA_REFERENCE)
private Integer afaReference;
public static final String SERIALIZED_NAME_INSTRUMENT_ID = "instrument_id";
@SerializedName(SERIALIZED_NAME_INSTRUMENT_ID)
private String instrumentId;
/** Type of the saved instrument */
@JsonAdapter(InstrumentTypeEnum.Adapter.class)
public enum InstrumentTypeEnum {
CARD("card");
private String value;
InstrumentTypeEnum(String value) {
this.value = value;
}
public String getValue() {
return value;
}
@Override
public String toString() {
return String.valueOf(value);
}
public static InstrumentTypeEnum fromValue(String value) {
for (InstrumentTypeEnum b : InstrumentTypeEnum.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 InstrumentTypeEnum enumeration)
throws IOException {
jsonWriter.value(enumeration.getValue());
}
@Override
public InstrumentTypeEnum read(final JsonReader jsonReader) throws IOException {
String value = jsonReader.nextString();
return InstrumentTypeEnum.fromValue(value);
}
}
}
public static final String SERIALIZED_NAME_INSTRUMENT_TYPE = "instrument_type";
@SerializedName(SERIALIZED_NAME_INSTRUMENT_TYPE)
private InstrumentTypeEnum instrumentType;
public static final String SERIALIZED_NAME_INSTRUMENT_UID = "instrument_uid";
@SerializedName(SERIALIZED_NAME_INSTRUMENT_UID)
private String instrumentUid;
public static final String SERIALIZED_NAME_INSTRUMENT_DISPLAY = "instrument_display";
@SerializedName(SERIALIZED_NAME_INSTRUMENT_DISPLAY)
private String instrumentDisplay;
/** status of the saved instrument */
@JsonAdapter(InstrumentStatusEnum.Adapter.class)
public enum InstrumentStatusEnum {
ACTIVE("ACTIVE"),
INACTIVE("INACTIVE");
private String value;
InstrumentStatusEnum(String value) {
this.value = value;
}
public String getValue() {
return value;
}
@Override
public String toString() {
return String.valueOf(value);
}
public static InstrumentStatusEnum fromValue(String value) {
for (InstrumentStatusEnum b : InstrumentStatusEnum.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 InstrumentStatusEnum enumeration)
throws IOException {
jsonWriter.value(enumeration.getValue());
}
@Override
public InstrumentStatusEnum read(final JsonReader jsonReader) throws IOException {
String value = jsonReader.nextString();
return InstrumentStatusEnum.fromValue(value);
}
}
}
public static final String SERIALIZED_NAME_INSTRUMENT_STATUS = "instrument_status";
@SerializedName(SERIALIZED_NAME_INSTRUMENT_STATUS)
private InstrumentStatusEnum instrumentStatus;
public static final String SERIALIZED_NAME_CREATED_AT = "created_at";
@SerializedName(SERIALIZED_NAME_CREATED_AT)
private String createdAt;
public static final String SERIALIZED_NAME_INSTRUMENT_META = "instrument_meta";
@SerializedName(SERIALIZED_NAME_INSTRUMENT_META)
private CFSavedInstrumentMeta instrumentMeta;
public CFFetchAllSavedInstruments() {}
public CFFetchAllSavedInstruments customerId(String customerId) {
this.customerId = customerId;
return this;
}
/**
* customer_id for which the instrument was saved
*
* @return customerId
*/
@javax.annotation.Nullable
public String getCustomerId() {
return customerId;
}
public void setCustomerId(String customerId) {
this.customerId = customerId;
}
public CFFetchAllSavedInstruments afaReference(Integer afaReference) {
this.afaReference = afaReference;
return this;
}
/**
* cf_payment_id of the successful transaction done while saving instrument
*
* @return afaReference
*/
@javax.annotation.Nullable
public Integer getAfaReference() {
return afaReference;
}
public void setAfaReference(Integer afaReference) {
this.afaReference = afaReference;
}
public CFFetchAllSavedInstruments instrumentId(String instrumentId) {
this.instrumentId = instrumentId;
return this;
}
/**
* saved instrument id
*
* @return instrumentId
*/
@javax.annotation.Nullable
public String getInstrumentId() {
return instrumentId;
}
public void setInstrumentId(String instrumentId) {
this.instrumentId = instrumentId;
}
public CFFetchAllSavedInstruments instrumentType(InstrumentTypeEnum instrumentType) {
this.instrumentType = instrumentType;
return this;
}
/**
* Type of the saved instrument
*
* @return instrumentType
*/
@javax.annotation.Nullable
public InstrumentTypeEnum getInstrumentType() {
return instrumentType;
}
public void setInstrumentType(InstrumentTypeEnum instrumentType) {
this.instrumentType = instrumentType;
}
public CFFetchAllSavedInstruments instrumentUid(String instrumentUid) {
this.instrumentUid = instrumentUid;
return this;
}
/**
* Unique id for the saved instrument
*
* @return instrumentUid
*/
@javax.annotation.Nullable
public String getInstrumentUid() {
return instrumentUid;
}
public void setInstrumentUid(String instrumentUid) {
this.instrumentUid = instrumentUid;
}
public CFFetchAllSavedInstruments instrumentDisplay(String instrumentDisplay) {
this.instrumentDisplay = instrumentDisplay;
return this;
}
/**
* masked card number displayed to the customer
*
* @return instrumentDisplay
*/
@javax.annotation.Nullable
public String getInstrumentDisplay() {
return instrumentDisplay;
}
public void setInstrumentDisplay(String instrumentDisplay) {
this.instrumentDisplay = instrumentDisplay;
}
public CFFetchAllSavedInstruments instrumentStatus(InstrumentStatusEnum instrumentStatus) {
this.instrumentStatus = instrumentStatus;
return this;
}
/**
* status of the saved instrument
*
* @return instrumentStatus
*/
@javax.annotation.Nullable
public InstrumentStatusEnum getInstrumentStatus() {
return instrumentStatus;
}
public void setInstrumentStatus(InstrumentStatusEnum instrumentStatus) {
this.instrumentStatus = instrumentStatus;
}
public CFFetchAllSavedInstruments createdAt(String createdAt) {
this.createdAt = createdAt;
return this;
}
/**
* timestamp at which instrument was saved
*
* @return createdAt
*/
@javax.annotation.Nullable
public String getCreatedAt() {
return createdAt;
}
public void setCreatedAt(String createdAt) {
this.createdAt = createdAt;
}
public CFFetchAllSavedInstruments instrumentMeta(CFSavedInstrumentMeta instrumentMeta) {
this.instrumentMeta = instrumentMeta;
return this;
}
/**
* Get instrumentMeta
*
* @return instrumentMeta
*/
@javax.annotation.Nullable
public CFSavedInstrumentMeta getInstrumentMeta() {
return instrumentMeta;
}
public void setInstrumentMeta(CFSavedInstrumentMeta instrumentMeta) {
this.instrumentMeta = instrumentMeta;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
CFFetchAllSavedInstruments cfFetchAllSavedInstruments = (CFFetchAllSavedInstruments) o;
return Objects.equals(this.customerId, cfFetchAllSavedInstruments.customerId)
&& Objects.equals(this.afaReference, cfFetchAllSavedInstruments.afaReference)
&& Objects.equals(this.instrumentId, cfFetchAllSavedInstruments.instrumentId)
&& Objects.equals(this.instrumentType, cfFetchAllSavedInstruments.instrumentType)
&& Objects.equals(this.instrumentUid, cfFetchAllSavedInstruments.instrumentUid)
&& Objects.equals(
this.instrumentDisplay, cfFetchAllSavedInstruments.instrumentDisplay)
&& Objects.equals(
this.instrumentStatus, cfFetchAllSavedInstruments.instrumentStatus)
&& Objects.equals(this.createdAt, cfFetchAllSavedInstruments.createdAt)
&& Objects.equals(this.instrumentMeta, cfFetchAllSavedInstruments.instrumentMeta);
}
@Override
public int hashCode() {
return Objects.hash(
customerId,
afaReference,
instrumentId,
instrumentType,
instrumentUid,
instrumentDisplay,
instrumentStatus,
createdAt,
instrumentMeta);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class CFFetchAllSavedInstruments {\n");
sb.append(" customerId: ").append(toIndentedString(customerId)).append("\n");
sb.append(" afaReference: ").append(toIndentedString(afaReference)).append("\n");
sb.append(" instrumentId: ").append(toIndentedString(instrumentId)).append("\n");
sb.append(" instrumentType: ").append(toIndentedString(instrumentType)).append("\n");
sb.append(" instrumentUid: ").append(toIndentedString(instrumentUid)).append("\n");
sb.append(" instrumentDisplay: ")
.append(toIndentedString(instrumentDisplay))
.append("\n");
sb.append(" instrumentStatus: ").append(toIndentedString(instrumentStatus)).append("\n");
sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n");
sb.append(" instrumentMeta: ").append(toIndentedString(instrumentMeta)).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("customer_id");
openapiFields.add("afa_reference");
openapiFields.add("instrument_id");
openapiFields.add("instrument_type");
openapiFields.add("instrument_uid");
openapiFields.add("instrument_display");
openapiFields.add("instrument_status");
openapiFields.add("created_at");
openapiFields.add("instrument_meta");
// 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 CFFetchAllSavedInstruments
*/
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
if (jsonObj == null) {
if (!CFFetchAllSavedInstruments.openapiRequiredFields
.isEmpty()) { // has required fields but JSON object is null
throw new IllegalArgumentException(
String.format(
"The required field(s) %s in CFFetchAllSavedInstruments is not"
+ " found in the empty JSON string",
CFFetchAllSavedInstruments.openapiRequiredFields.toString()));
}
}
Set> entries = jsonObj.entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!CFFetchAllSavedInstruments.openapiFields.contains(entry.getKey())) {
throw new IllegalArgumentException(
String.format(
"The field `%s` in the JSON string is not defined in the"
+ " `CFFetchAllSavedInstruments` properties. JSON: %s",
entry.getKey(), jsonObj.toString()));
}
}
if ((jsonObj.get("customer_id") != null && !jsonObj.get("customer_id").isJsonNull())
&& !jsonObj.get("customer_id").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
"Expected the field `customer_id` to be a primitive type in the JSON"
+ " string but got `%s`",
jsonObj.get("customer_id").toString()));
}
if ((jsonObj.get("instrument_id") != null && !jsonObj.get("instrument_id").isJsonNull())
&& !jsonObj.get("instrument_id").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
"Expected the field `instrument_id` to be a primitive type in the JSON"
+ " string but got `%s`",
jsonObj.get("instrument_id").toString()));
}
if ((jsonObj.get("instrument_type") != null && !jsonObj.get("instrument_type").isJsonNull())
&& !jsonObj.get("instrument_type").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
"Expected the field `instrument_type` to be a primitive type in the"
+ " JSON string but got `%s`",
jsonObj.get("instrument_type").toString()));
}
if ((jsonObj.get("instrument_uid") != null && !jsonObj.get("instrument_uid").isJsonNull())
&& !jsonObj.get("instrument_uid").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
"Expected the field `instrument_uid` to be a primitive type in the"
+ " JSON string but got `%s`",
jsonObj.get("instrument_uid").toString()));
}
if ((jsonObj.get("instrument_display") != null
&& !jsonObj.get("instrument_display").isJsonNull())
&& !jsonObj.get("instrument_display").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
"Expected the field `instrument_display` to be a primitive type in the"
+ " JSON string but got `%s`",
jsonObj.get("instrument_display").toString()));
}
if ((jsonObj.get("instrument_status") != null
&& !jsonObj.get("instrument_status").isJsonNull())
&& !jsonObj.get("instrument_status").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
"Expected the field `instrument_status` to be a primitive type in the"
+ " JSON string but got `%s`",
jsonObj.get("instrument_status").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()));
}
// validate the optional field `instrument_meta`
if (jsonObj.get("instrument_meta") != null
&& !jsonObj.get("instrument_meta").isJsonNull()) {
CFSavedInstrumentMeta.validateJsonObject(jsonObj.getAsJsonObject("instrument_meta"));
}
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@SuppressWarnings("unchecked")
@Override
public TypeAdapter create(Gson gson, TypeToken type) {
if (!CFFetchAllSavedInstruments.class.isAssignableFrom(type.getRawType())) {
return null; // this class only serializes 'CFFetchAllSavedInstruments' and its
// subtypes
}
final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
final TypeAdapter thisAdapter =
gson.getDelegateAdapter(this, TypeToken.get(CFFetchAllSavedInstruments.class));
return (TypeAdapter)
new TypeAdapter() {
@Override
public void write(JsonWriter out, CFFetchAllSavedInstruments value)
throws IOException {
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
elementAdapter.write(out, obj);
}
@Override
public CFFetchAllSavedInstruments read(JsonReader in) throws IOException {
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
validateJsonObject(jsonObj);
return thisAdapter.fromJsonTree(jsonObj);
}
}.nullSafe();
}
}
/**
* Create an instance of CFFetchAllSavedInstruments given an JSON string
*
* @param jsonString JSON string
* @return An instance of CFFetchAllSavedInstruments
* @throws IOException if the JSON string is invalid with respect to CFFetchAllSavedInstruments
*/
public static CFFetchAllSavedInstruments fromJson(String jsonString) throws IOException {
return JSON.getGson().fromJson(jsonString, CFFetchAllSavedInstruments.class);
}
/**
* Convert an instance of CFFetchAllSavedInstruments to an JSON string
*
* @return JSON string
*/
public String toJson() {
return JSON.getGson().toJson(this);
}
}