com.cashfree.pg.model.CFLinkRequest 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.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.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
/** CFLinkRequest */
@javax.annotation.Generated(
value = "org.openapitools.codegen.languages.JavaClientCodegen",
date = "2023-03-16T14:01:52.135917+05:30[Asia/Kolkata]")
public class CFLinkRequest {
public static final String SERIALIZED_NAME_LINK_ID = "link_id";
@SerializedName(SERIALIZED_NAME_LINK_ID)
private String linkId;
public static final String SERIALIZED_NAME_LINK_AMOUNT = "link_amount";
@SerializedName(SERIALIZED_NAME_LINK_AMOUNT)
private Double linkAmount;
public static final String SERIALIZED_NAME_LINK_CURRENCY = "link_currency";
@SerializedName(SERIALIZED_NAME_LINK_CURRENCY)
private String linkCurrency;
public static final String SERIALIZED_NAME_LINK_PURPOSE = "link_purpose";
@SerializedName(SERIALIZED_NAME_LINK_PURPOSE)
private String linkPurpose;
public static final String SERIALIZED_NAME_CUSTOMER_DETAILS = "customer_details";
@SerializedName(SERIALIZED_NAME_CUSTOMER_DETAILS)
private CFLinkCustomerDetailsEntity customerDetails;
public static final String SERIALIZED_NAME_LINK_PARTIAL_PAYMENTS = "link_partial_payments";
@SerializedName(SERIALIZED_NAME_LINK_PARTIAL_PAYMENTS)
private Boolean linkPartialPayments;
public static final String SERIALIZED_NAME_LINK_MINIMUM_PARTIAL_AMOUNT =
"link_minimum_partial_amount";
@SerializedName(SERIALIZED_NAME_LINK_MINIMUM_PARTIAL_AMOUNT)
private Double linkMinimumPartialAmount;
public static final String SERIALIZED_NAME_LINK_EXPIRY_TIME = "link_expiry_time";
@SerializedName(SERIALIZED_NAME_LINK_EXPIRY_TIME)
private String linkExpiryTime;
public static final String SERIALIZED_NAME_LINK_NOTIFY = "link_notify";
@SerializedName(SERIALIZED_NAME_LINK_NOTIFY)
private CFLinkNotifyEntity linkNotify;
public static final String SERIALIZED_NAME_LINK_AUTO_REMINDERS = "link_auto_reminders";
@SerializedName(SERIALIZED_NAME_LINK_AUTO_REMINDERS)
private Boolean linkAutoReminders;
public static final String SERIALIZED_NAME_LINK_NOTES = "link_notes";
@SerializedName(SERIALIZED_NAME_LINK_NOTES)
private Map linkNotes = new HashMap<>();
public static final String SERIALIZED_NAME_LINK_META = "link_meta";
@SerializedName(SERIALIZED_NAME_LINK_META)
private CFLinkMetaEntity linkMeta;
public CFLinkRequest() {}
public CFLinkRequest linkId(String linkId) {
this.linkId = linkId;
return this;
}
/**
* Unique Identifier (provided by merchant) for the Link. Alphanumeric and only - and _ allowed
* (50 character limit). Use this for other link-related APIs.
*
* @return linkId
*/
@javax.annotation.Nonnull
public String getLinkId() {
return linkId;
}
public void setLinkId(String linkId) {
this.linkId = linkId;
}
public CFLinkRequest linkAmount(Double linkAmount) {
this.linkAmount = linkAmount;
return this;
}
/**
* Amount to be collected using this link. Provide upto two decimals for paise.
*
* @return linkAmount
*/
@javax.annotation.Nonnull
public Double getLinkAmount() {
return linkAmount;
}
public void setLinkAmount(Double linkAmount) {
this.linkAmount = linkAmount;
}
public CFLinkRequest linkCurrency(String linkCurrency) {
this.linkCurrency = linkCurrency;
return this;
}
/**
* Currency for the payment link. Default is INR. Contact [email protected] to enable new
* currencies.
*
* @return linkCurrency
*/
@javax.annotation.Nonnull
public String getLinkCurrency() {
return linkCurrency;
}
public void setLinkCurrency(String linkCurrency) {
this.linkCurrency = linkCurrency;
}
public CFLinkRequest linkPurpose(String linkPurpose) {
this.linkPurpose = linkPurpose;
return this;
}
/**
* A brief description for which payment must be collected. This is shown to the customer.
*
* @return linkPurpose
*/
@javax.annotation.Nonnull
public String getLinkPurpose() {
return linkPurpose;
}
public void setLinkPurpose(String linkPurpose) {
this.linkPurpose = linkPurpose;
}
public CFLinkRequest customerDetails(CFLinkCustomerDetailsEntity customerDetails) {
this.customerDetails = customerDetails;
return this;
}
/**
* Get customerDetails
*
* @return customerDetails
*/
@javax.annotation.Nonnull
public CFLinkCustomerDetailsEntity getCustomerDetails() {
return customerDetails;
}
public void setCustomerDetails(CFLinkCustomerDetailsEntity customerDetails) {
this.customerDetails = customerDetails;
}
public CFLinkRequest linkPartialPayments(Boolean linkPartialPayments) {
this.linkPartialPayments = linkPartialPayments;
return this;
}
/**
* If \"true\", customer can make partial payments for the link.
*
* @return linkPartialPayments
*/
@javax.annotation.Nullable
public Boolean getLinkPartialPayments() {
return linkPartialPayments;
}
public void setLinkPartialPayments(Boolean linkPartialPayments) {
this.linkPartialPayments = linkPartialPayments;
}
public CFLinkRequest linkMinimumPartialAmount(Double linkMinimumPartialAmount) {
this.linkMinimumPartialAmount = linkMinimumPartialAmount;
return this;
}
/**
* Minimum amount in first installment that needs to be paid by the customer if partial payments
* are enabled. This should be less than the link_amount.
*
* @return linkMinimumPartialAmount
*/
@javax.annotation.Nullable
public Double getLinkMinimumPartialAmount() {
return linkMinimumPartialAmount;
}
public void setLinkMinimumPartialAmount(Double linkMinimumPartialAmount) {
this.linkMinimumPartialAmount = linkMinimumPartialAmount;
}
public CFLinkRequest linkExpiryTime(String linkExpiryTime) {
this.linkExpiryTime = linkExpiryTime;
return this;
}
/**
* Time after which the link expires. Customers will not be able to make the payment beyond the
* time specified here. You can provide them in a valid ISO 8601 time format. Default is 30
* days.
*
* @return linkExpiryTime
*/
@javax.annotation.Nullable
public String getLinkExpiryTime() {
return linkExpiryTime;
}
public void setLinkExpiryTime(String linkExpiryTime) {
this.linkExpiryTime = linkExpiryTime;
}
public CFLinkRequest linkNotify(CFLinkNotifyEntity linkNotify) {
this.linkNotify = linkNotify;
return this;
}
/**
* Get linkNotify
*
* @return linkNotify
*/
@javax.annotation.Nullable
public CFLinkNotifyEntity getLinkNotify() {
return linkNotify;
}
public void setLinkNotify(CFLinkNotifyEntity linkNotify) {
this.linkNotify = linkNotify;
}
public CFLinkRequest linkAutoReminders(Boolean linkAutoReminders) {
this.linkAutoReminders = linkAutoReminders;
return this;
}
/**
* If \"true\", reminders will be sent to customers for collecting payments.
*
* @return linkAutoReminders
*/
@javax.annotation.Nullable
public Boolean getLinkAutoReminders() {
return linkAutoReminders;
}
public void setLinkAutoReminders(Boolean linkAutoReminders) {
this.linkAutoReminders = linkAutoReminders;
}
public CFLinkRequest linkNotes(Map linkNotes) {
this.linkNotes = linkNotes;
return this;
}
public CFLinkRequest putLinkNotesItem(String key, String linkNotesItem) {
if (this.linkNotes == null) {
this.linkNotes = new HashMap<>();
}
this.linkNotes.put(key, linkNotesItem);
return this;
}
/**
* Key-value pair that can be used to store additional information about the entity. Maximum 5
* key-value pairs
*
* @return linkNotes
*/
@javax.annotation.Nullable
public Map getLinkNotes() {
return linkNotes;
}
public void setLinkNotes(Map linkNotes) {
this.linkNotes = linkNotes;
}
public CFLinkRequest linkMeta(CFLinkMetaEntity linkMeta) {
this.linkMeta = linkMeta;
return this;
}
/**
* Get linkMeta
*
* @return linkMeta
*/
@javax.annotation.Nullable
public CFLinkMetaEntity getLinkMeta() {
return linkMeta;
}
public void setLinkMeta(CFLinkMetaEntity linkMeta) {
this.linkMeta = linkMeta;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
CFLinkRequest cfLinkRequest = (CFLinkRequest) o;
return Objects.equals(this.linkId, cfLinkRequest.linkId)
&& Objects.equals(this.linkAmount, cfLinkRequest.linkAmount)
&& Objects.equals(this.linkCurrency, cfLinkRequest.linkCurrency)
&& Objects.equals(this.linkPurpose, cfLinkRequest.linkPurpose)
&& Objects.equals(this.customerDetails, cfLinkRequest.customerDetails)
&& Objects.equals(this.linkPartialPayments, cfLinkRequest.linkPartialPayments)
&& Objects.equals(
this.linkMinimumPartialAmount, cfLinkRequest.linkMinimumPartialAmount)
&& Objects.equals(this.linkExpiryTime, cfLinkRequest.linkExpiryTime)
&& Objects.equals(this.linkNotify, cfLinkRequest.linkNotify)
&& Objects.equals(this.linkAutoReminders, cfLinkRequest.linkAutoReminders)
&& Objects.equals(this.linkNotes, cfLinkRequest.linkNotes)
&& Objects.equals(this.linkMeta, cfLinkRequest.linkMeta);
}
@Override
public int hashCode() {
return Objects.hash(
linkId,
linkAmount,
linkCurrency,
linkPurpose,
customerDetails,
linkPartialPayments,
linkMinimumPartialAmount,
linkExpiryTime,
linkNotify,
linkAutoReminders,
linkNotes,
linkMeta);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class CFLinkRequest {\n");
sb.append(" linkId: ").append(toIndentedString(linkId)).append("\n");
sb.append(" linkAmount: ").append(toIndentedString(linkAmount)).append("\n");
sb.append(" linkCurrency: ").append(toIndentedString(linkCurrency)).append("\n");
sb.append(" linkPurpose: ").append(toIndentedString(linkPurpose)).append("\n");
sb.append(" customerDetails: ").append(toIndentedString(customerDetails)).append("\n");
sb.append(" linkPartialPayments: ")
.append(toIndentedString(linkPartialPayments))
.append("\n");
sb.append(" linkMinimumPartialAmount: ")
.append(toIndentedString(linkMinimumPartialAmount))
.append("\n");
sb.append(" linkExpiryTime: ").append(toIndentedString(linkExpiryTime)).append("\n");
sb.append(" linkNotify: ").append(toIndentedString(linkNotify)).append("\n");
sb.append(" linkAutoReminders: ")
.append(toIndentedString(linkAutoReminders))
.append("\n");
sb.append(" linkNotes: ").append(toIndentedString(linkNotes)).append("\n");
sb.append(" linkMeta: ").append(toIndentedString(linkMeta)).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("link_id");
openapiFields.add("link_amount");
openapiFields.add("link_currency");
openapiFields.add("link_purpose");
openapiFields.add("customer_details");
openapiFields.add("link_partial_payments");
openapiFields.add("link_minimum_partial_amount");
openapiFields.add("link_expiry_time");
openapiFields.add("link_notify");
openapiFields.add("link_auto_reminders");
openapiFields.add("link_notes");
openapiFields.add("link_meta");
// a set of required properties/fields (JSON key names)
openapiRequiredFields = new HashSet();
openapiRequiredFields.add("link_id");
openapiRequiredFields.add("link_amount");
openapiRequiredFields.add("link_currency");
openapiRequiredFields.add("link_purpose");
openapiRequiredFields.add("customer_details");
}
/**
* 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 CFLinkRequest
*/
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
if (jsonObj == null) {
if (!CFLinkRequest.openapiRequiredFields
.isEmpty()) { // has required fields but JSON object is null
throw new IllegalArgumentException(
String.format(
"The required field(s) %s in CFLinkRequest is not found in the"
+ " empty JSON string",
CFLinkRequest.openapiRequiredFields.toString()));
}
}
Set> entries = jsonObj.entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!CFLinkRequest.openapiFields.contains(entry.getKey())) {
throw new IllegalArgumentException(
String.format(
"The field `%s` in the JSON string is not defined in the"
+ " `CFLinkRequest` properties. JSON: %s",
entry.getKey(), jsonObj.toString()));
}
}
// check to make sure all required properties/fields are present in the JSON string
for (String requiredField : CFLinkRequest.openapiRequiredFields) {
if (jsonObj.get(requiredField) == null) {
throw new IllegalArgumentException(
String.format(
"The required field `%s` is not found in the JSON string: %s",
requiredField, jsonObj.toString()));
}
}
if (!jsonObj.get("link_id").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
"Expected the field `link_id` to be a primitive type in the JSON"
+ " string but got `%s`",
jsonObj.get("link_id").toString()));
}
if (!jsonObj.get("link_currency").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
"Expected the field `link_currency` to be a primitive type in the JSON"
+ " string but got `%s`",
jsonObj.get("link_currency").toString()));
}
if (!jsonObj.get("link_purpose").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
"Expected the field `link_purpose` to be a primitive type in the JSON"
+ " string but got `%s`",
jsonObj.get("link_purpose").toString()));
}
// validate the required field `customer_details`
CFLinkCustomerDetailsEntity.validateJsonObject(jsonObj.getAsJsonObject("customer_details"));
if ((jsonObj.get("link_expiry_time") != null
&& !jsonObj.get("link_expiry_time").isJsonNull())
&& !jsonObj.get("link_expiry_time").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
"Expected the field `link_expiry_time` to be a primitive type in the"
+ " JSON string but got `%s`",
jsonObj.get("link_expiry_time").toString()));
}
// validate the optional field `link_notify`
if (jsonObj.get("link_notify") != null && !jsonObj.get("link_notify").isJsonNull()) {
CFLinkNotifyEntity.validateJsonObject(jsonObj.getAsJsonObject("link_notify"));
}
// validate the optional field `link_meta`
if (jsonObj.get("link_meta") != null && !jsonObj.get("link_meta").isJsonNull()) {
CFLinkMetaEntity.validateJsonObject(jsonObj.getAsJsonObject("link_meta"));
}
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@SuppressWarnings("unchecked")
@Override
public TypeAdapter create(Gson gson, TypeToken type) {
if (!CFLinkRequest.class.isAssignableFrom(type.getRawType())) {
return null; // this class only serializes 'CFLinkRequest' and its subtypes
}
final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
final TypeAdapter thisAdapter =
gson.getDelegateAdapter(this, TypeToken.get(CFLinkRequest.class));
return (TypeAdapter)
new TypeAdapter() {
@Override
public void write(JsonWriter out, CFLinkRequest value) throws IOException {
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
elementAdapter.write(out, obj);
}
@Override
public CFLinkRequest read(JsonReader in) throws IOException {
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
validateJsonObject(jsonObj);
return thisAdapter.fromJsonTree(jsonObj);
}
}.nullSafe();
}
}
/**
* Create an instance of CFLinkRequest given an JSON string
*
* @param jsonString JSON string
* @return An instance of CFLinkRequest
* @throws IOException if the JSON string is invalid with respect to CFLinkRequest
*/
public static CFLinkRequest fromJson(String jsonString) throws IOException {
return JSON.getGson().fromJson(jsonString, CFLinkRequest.class);
}
/**
* Convert an instance of CFLinkRequest to an JSON string
*
* @return JSON string
*/
public String toJson() {
return JSON.getGson().toJson(this);
}
}