All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.cashfree.pg.model.CFLinkOrders Maven / Gradle / Ivy

There is a newer version: 2.1.7
Show newest version
/*
 * 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.math.BigDecimal;
import java.util.HashSet;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;

/** CFLinkOrders */
@javax.annotation.Generated(
        value = "org.openapitools.codegen.languages.JavaClientCodegen",
        date = "2023-03-16T14:01:52.135917+05:30[Asia/Kolkata]")
public class CFLinkOrders {
    public static final String SERIALIZED_NAME_CF_ORDER_ID = "cf_order_id";

    @SerializedName(SERIALIZED_NAME_CF_ORDER_ID)
    private Integer cfOrderId;

    public static final String SERIALIZED_NAME_ORDER_ID = "order_id";

    @SerializedName(SERIALIZED_NAME_ORDER_ID)
    private String orderId;

    public static final String SERIALIZED_NAME_ENTITY = "entity";

    @SerializedName(SERIALIZED_NAME_ENTITY)
    private String entity;

    public static final String SERIALIZED_NAME_ORDER_CURRENCY = "order_currency";

    @SerializedName(SERIALIZED_NAME_ORDER_CURRENCY)
    private String orderCurrency;

    public static final String SERIALIZED_NAME_ORDER_AMOUNT = "order_amount";

    @SerializedName(SERIALIZED_NAME_ORDER_AMOUNT)
    private BigDecimal orderAmount;

    public static final String SERIALIZED_NAME_ORDER_STATUS = "order_status";

    @SerializedName(SERIALIZED_NAME_ORDER_STATUS)
    private String orderStatus;

    public static final String SERIALIZED_NAME_ORDER_TOKEN = "order_token";

    @SerializedName(SERIALIZED_NAME_ORDER_TOKEN)
    private String orderToken;

    public static final String SERIALIZED_NAME_ORDER_EXPIRY_TIME = "order_expiry_time";

    @SerializedName(SERIALIZED_NAME_ORDER_EXPIRY_TIME)
    private String orderExpiryTime;

    public static final String SERIALIZED_NAME_ORDER_NOTE = "order_note";

    @SerializedName(SERIALIZED_NAME_ORDER_NOTE)
    private String orderNote;

    public static final String SERIALIZED_NAME_CUSTOMER_DETAILS = "customer_details";

    @SerializedName(SERIALIZED_NAME_CUSTOMER_DETAILS)
    private CFLinkCustomerDetailsEntity customerDetails;

    public static final String SERIALIZED_NAME_PAYMENTS = "payments";

    @SerializedName(SERIALIZED_NAME_PAYMENTS)
    private CFPaymentURLObject payments;

    public static final String SERIALIZED_NAME_SETTLEMENTS = "settlements";

    @SerializedName(SERIALIZED_NAME_SETTLEMENTS)
    private CFSettlementURLObject settlements;

    public static final String SERIALIZED_NAME_REFUNDS = "refunds";

    @SerializedName(SERIALIZED_NAME_REFUNDS)
    private CFRefundURLObject refunds;

    public CFLinkOrders() {}

    public CFLinkOrders cfOrderId(Integer cfOrderId) {

        this.cfOrderId = cfOrderId;
        return this;
    }

    /**
     * Get cfOrderId
     *
     * @return cfOrderId
     */
    @javax.annotation.Nullable
    public Integer getCfOrderId() {
        return cfOrderId;
    }

    public void setCfOrderId(Integer cfOrderId) {
        this.cfOrderId = cfOrderId;
    }

    public CFLinkOrders orderId(String orderId) {

        this.orderId = orderId;
        return this;
    }

    /**
     * Get orderId
     *
     * @return orderId
     */
    @javax.annotation.Nullable
    public String getOrderId() {
        return orderId;
    }

    public void setOrderId(String orderId) {
        this.orderId = orderId;
    }

    public CFLinkOrders entity(String entity) {

        this.entity = entity;
        return this;
    }

    /**
     * Get entity
     *
     * @return entity
     */
    @javax.annotation.Nullable
    public String getEntity() {
        return entity;
    }

    public void setEntity(String entity) {
        this.entity = entity;
    }

    public CFLinkOrders orderCurrency(String orderCurrency) {

        this.orderCurrency = orderCurrency;
        return this;
    }

    /**
     * Get orderCurrency
     *
     * @return orderCurrency
     */
    @javax.annotation.Nullable
    public String getOrderCurrency() {
        return orderCurrency;
    }

    public void setOrderCurrency(String orderCurrency) {
        this.orderCurrency = orderCurrency;
    }

    public CFLinkOrders orderAmount(BigDecimal orderAmount) {

        this.orderAmount = orderAmount;
        return this;
    }

    /**
     * Get orderAmount
     *
     * @return orderAmount
     */
    @javax.annotation.Nullable
    public BigDecimal getOrderAmount() {
        return orderAmount;
    }

    public void setOrderAmount(BigDecimal orderAmount) {
        this.orderAmount = orderAmount;
    }

    public CFLinkOrders orderStatus(String orderStatus) {

        this.orderStatus = orderStatus;
        return this;
    }

    /**
     * Get orderStatus
     *
     * @return orderStatus
     */
    @javax.annotation.Nullable
    public String getOrderStatus() {
        return orderStatus;
    }

    public void setOrderStatus(String orderStatus) {
        this.orderStatus = orderStatus;
    }

    public CFLinkOrders orderToken(String orderToken) {

        this.orderToken = orderToken;
        return this;
    }

    /**
     * Get orderToken
     *
     * @return orderToken
     */
    @javax.annotation.Nullable
    public String getOrderToken() {
        return orderToken;
    }

    public void setOrderToken(String orderToken) {
        this.orderToken = orderToken;
    }

    public CFLinkOrders orderExpiryTime(String orderExpiryTime) {

        this.orderExpiryTime = orderExpiryTime;
        return this;
    }

    /**
     * Get orderExpiryTime
     *
     * @return orderExpiryTime
     */
    @javax.annotation.Nullable
    public String getOrderExpiryTime() {
        return orderExpiryTime;
    }

    public void setOrderExpiryTime(String orderExpiryTime) {
        this.orderExpiryTime = orderExpiryTime;
    }

    public CFLinkOrders orderNote(String orderNote) {

        this.orderNote = orderNote;
        return this;
    }

    /**
     * Get orderNote
     *
     * @return orderNote
     */
    @javax.annotation.Nullable
    public String getOrderNote() {
        return orderNote;
    }

    public void setOrderNote(String orderNote) {
        this.orderNote = orderNote;
    }

    public CFLinkOrders customerDetails(CFLinkCustomerDetailsEntity customerDetails) {

        this.customerDetails = customerDetails;
        return this;
    }

    /**
     * Get customerDetails
     *
     * @return customerDetails
     */
    @javax.annotation.Nullable
    public CFLinkCustomerDetailsEntity getCustomerDetails() {
        return customerDetails;
    }

    public void setCustomerDetails(CFLinkCustomerDetailsEntity customerDetails) {
        this.customerDetails = customerDetails;
    }

    public CFLinkOrders payments(CFPaymentURLObject payments) {

        this.payments = payments;
        return this;
    }

    /**
     * Get payments
     *
     * @return payments
     */
    @javax.annotation.Nullable
    public CFPaymentURLObject getPayments() {
        return payments;
    }

    public void setPayments(CFPaymentURLObject payments) {
        this.payments = payments;
    }

    public CFLinkOrders settlements(CFSettlementURLObject settlements) {

        this.settlements = settlements;
        return this;
    }

    /**
     * Get settlements
     *
     * @return settlements
     */
    @javax.annotation.Nullable
    public CFSettlementURLObject getSettlements() {
        return settlements;
    }

    public void setSettlements(CFSettlementURLObject settlements) {
        this.settlements = settlements;
    }

    public CFLinkOrders refunds(CFRefundURLObject refunds) {

        this.refunds = refunds;
        return this;
    }

    /**
     * Get refunds
     *
     * @return refunds
     */
    @javax.annotation.Nullable
    public CFRefundURLObject getRefunds() {
        return refunds;
    }

    public void setRefunds(CFRefundURLObject refunds) {
        this.refunds = refunds;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        CFLinkOrders cfLinkOrders = (CFLinkOrders) o;
        return Objects.equals(this.cfOrderId, cfLinkOrders.cfOrderId)
                && Objects.equals(this.orderId, cfLinkOrders.orderId)
                && Objects.equals(this.entity, cfLinkOrders.entity)
                && Objects.equals(this.orderCurrency, cfLinkOrders.orderCurrency)
                && Objects.equals(this.orderAmount, cfLinkOrders.orderAmount)
                && Objects.equals(this.orderStatus, cfLinkOrders.orderStatus)
                && Objects.equals(this.orderToken, cfLinkOrders.orderToken)
                && Objects.equals(this.orderExpiryTime, cfLinkOrders.orderExpiryTime)
                && Objects.equals(this.orderNote, cfLinkOrders.orderNote)
                && Objects.equals(this.customerDetails, cfLinkOrders.customerDetails)
                && Objects.equals(this.payments, cfLinkOrders.payments)
                && Objects.equals(this.settlements, cfLinkOrders.settlements)
                && Objects.equals(this.refunds, cfLinkOrders.refunds);
    }

    @Override
    public int hashCode() {
        return Objects.hash(
                cfOrderId,
                orderId,
                entity,
                orderCurrency,
                orderAmount,
                orderStatus,
                orderToken,
                orderExpiryTime,
                orderNote,
                customerDetails,
                payments,
                settlements,
                refunds);
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("class CFLinkOrders {\n");
        sb.append("    cfOrderId: ").append(toIndentedString(cfOrderId)).append("\n");
        sb.append("    orderId: ").append(toIndentedString(orderId)).append("\n");
        sb.append("    entity: ").append(toIndentedString(entity)).append("\n");
        sb.append("    orderCurrency: ").append(toIndentedString(orderCurrency)).append("\n");
        sb.append("    orderAmount: ").append(toIndentedString(orderAmount)).append("\n");
        sb.append("    orderStatus: ").append(toIndentedString(orderStatus)).append("\n");
        sb.append("    orderToken: ").append(toIndentedString(orderToken)).append("\n");
        sb.append("    orderExpiryTime: ").append(toIndentedString(orderExpiryTime)).append("\n");
        sb.append("    orderNote: ").append(toIndentedString(orderNote)).append("\n");
        sb.append("    customerDetails: ").append(toIndentedString(customerDetails)).append("\n");
        sb.append("    payments: ").append(toIndentedString(payments)).append("\n");
        sb.append("    settlements: ").append(toIndentedString(settlements)).append("\n");
        sb.append("    refunds: ").append(toIndentedString(refunds)).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_order_id");
        openapiFields.add("order_id");
        openapiFields.add("entity");
        openapiFields.add("order_currency");
        openapiFields.add("order_amount");
        openapiFields.add("order_status");
        openapiFields.add("order_token");
        openapiFields.add("order_expiry_time");
        openapiFields.add("order_note");
        openapiFields.add("customer_details");
        openapiFields.add("payments");
        openapiFields.add("settlements");
        openapiFields.add("refunds");

        // 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 CFLinkOrders
     */
    public static void validateJsonObject(JsonObject jsonObj) throws IOException {
        if (jsonObj == null) {
            if (!CFLinkOrders.openapiRequiredFields
                    .isEmpty()) { // has required fields but JSON object is null
                throw new IllegalArgumentException(
                        String.format(
                                "The required field(s) %s in CFLinkOrders is not found in the"
                                        + " empty JSON string",
                                CFLinkOrders.openapiRequiredFields.toString()));
            }
        }

        Set> entries = jsonObj.entrySet();
        // check to see if the JSON string contains additional fields
        for (Entry entry : entries) {
            if (!CFLinkOrders.openapiFields.contains(entry.getKey())) {
                throw new IllegalArgumentException(
                        String.format(
                                "The field `%s` in the JSON string is not defined in the"
                                        + " `CFLinkOrders` properties. JSON: %s",
                                entry.getKey(), jsonObj.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("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("order_currency") != null && !jsonObj.get("order_currency").isJsonNull())
                && !jsonObj.get("order_currency").isJsonPrimitive()) {
            throw new IllegalArgumentException(
                    String.format(
                            "Expected the field `order_currency` to be a primitive type in the"
                                    + " JSON string but got `%s`",
                            jsonObj.get("order_currency").toString()));
        }
        if ((jsonObj.get("order_status") != null && !jsonObj.get("order_status").isJsonNull())
                && !jsonObj.get("order_status").isJsonPrimitive()) {
            throw new IllegalArgumentException(
                    String.format(
                            "Expected the field `order_status` to be a primitive type in the JSON"
                                    + " string but got `%s`",
                            jsonObj.get("order_status").toString()));
        }
        if ((jsonObj.get("order_token") != null && !jsonObj.get("order_token").isJsonNull())
                && !jsonObj.get("order_token").isJsonPrimitive()) {
            throw new IllegalArgumentException(
                    String.format(
                            "Expected the field `order_token` to be a primitive type in the JSON"
                                    + " string but got `%s`",
                            jsonObj.get("order_token").toString()));
        }
        if ((jsonObj.get("order_expiry_time") != null
                        && !jsonObj.get("order_expiry_time").isJsonNull())
                && !jsonObj.get("order_expiry_time").isJsonPrimitive()) {
            throw new IllegalArgumentException(
                    String.format(
                            "Expected the field `order_expiry_time` to be a primitive type in the"
                                    + " JSON string but got `%s`",
                            jsonObj.get("order_expiry_time").toString()));
        }
        if ((jsonObj.get("order_note") != null && !jsonObj.get("order_note").isJsonNull())
                && !jsonObj.get("order_note").isJsonPrimitive()) {
            throw new IllegalArgumentException(
                    String.format(
                            "Expected the field `order_note` to be a primitive type in the JSON"
                                    + " string but got `%s`",
                            jsonObj.get("order_note").toString()));
        }
        // validate the optional field `customer_details`
        if (jsonObj.get("customer_details") != null
                && !jsonObj.get("customer_details").isJsonNull()) {
            CFLinkCustomerDetailsEntity.validateJsonObject(
                    jsonObj.getAsJsonObject("customer_details"));
        }
        // validate the optional field `payments`
        if (jsonObj.get("payments") != null && !jsonObj.get("payments").isJsonNull()) {
            CFPaymentURLObject.validateJsonObject(jsonObj.getAsJsonObject("payments"));
        }
        // validate the optional field `settlements`
        if (jsonObj.get("settlements") != null && !jsonObj.get("settlements").isJsonNull()) {
            CFSettlementURLObject.validateJsonObject(jsonObj.getAsJsonObject("settlements"));
        }
        // validate the optional field `refunds`
        if (jsonObj.get("refunds") != null && !jsonObj.get("refunds").isJsonNull()) {
            CFRefundURLObject.validateJsonObject(jsonObj.getAsJsonObject("refunds"));
        }
    }

    public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
        @SuppressWarnings("unchecked")
        @Override
        public  TypeAdapter create(Gson gson, TypeToken type) {
            if (!CFLinkOrders.class.isAssignableFrom(type.getRawType())) {
                return null; // this class only serializes 'CFLinkOrders' and its subtypes
            }
            final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
            final TypeAdapter thisAdapter =
                    gson.getDelegateAdapter(this, TypeToken.get(CFLinkOrders.class));

            return (TypeAdapter)
                    new TypeAdapter() {
                        @Override
                        public void write(JsonWriter out, CFLinkOrders value) throws IOException {
                            JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
                            elementAdapter.write(out, obj);
                        }

                        @Override
                        public CFLinkOrders read(JsonReader in) throws IOException {
                            JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
                            validateJsonObject(jsonObj);
                            return thisAdapter.fromJsonTree(jsonObj);
                        }
                    }.nullSafe();
        }
    }

    /**
     * Create an instance of CFLinkOrders given an JSON string
     *
     * @param jsonString JSON string
     * @return An instance of CFLinkOrders
     * @throws IOException if the JSON string is invalid with respect to CFLinkOrders
     */
    public static CFLinkOrders fromJson(String jsonString) throws IOException {
        return JSON.getGson().fromJson(jsonString, CFLinkOrders.class);
    }

    /**
     * Convert an instance of CFLinkOrders to an JSON string
     *
     * @return JSON string
     */
    public String toJson() {
        return JSON.getGson().toJson(this);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy