java/src/main/java/com/konfigthis/dojah/client/model/CreditSubwalletResponseEntity.java
/*
 * DOJAH APIs
 * Use Dojah to verify, onboard and manage user identity across Africa!
 *
 * The version of the OpenAPI document: 1.0.0
 * 
 *
 * NOTE: This class is auto generated by Konfig (https://konfigthis.com).
 * Do not edit the class manually.
 */


package com.konfigthis.dojah.client.model;

import java.util.Objects;
import java.util.Arrays;
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 io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.IOException;
import org.openapitools.jackson.nullable.JsonNullable;

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 org.apache.commons.lang3.StringUtils;

import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import com.konfigthis.dojah.client.JSON;

/**
 * CreditSubwalletResponseEntity
 */
@javax.annotation.Generated(value = "Generated by https://konfigthis.com")
public class CreditSubwalletResponseEntity {
  public static final String SERIALIZED_NAME_WALLET_ID = "wallet_id";
  @SerializedName(SERIALIZED_NAME_WALLET_ID)
  private String walletId;

  public static final String SERIALIZED_NAME_TRANSACTION_AMOUNT = "transaction_amount";
  @SerializedName(SERIALIZED_NAME_TRANSACTION_AMOUNT)
  private Double transactionAmount;

  public static final String SERIALIZED_NAME_TRANSACTION_TYPE = "transaction_type";
  @SerializedName(SERIALIZED_NAME_TRANSACTION_TYPE)
  private String transactionType;

  public static final String SERIALIZED_NAME_RECIPIENT_ACCOUNT_NUMBER = "recipient_account_number";
  @SerializedName(SERIALIZED_NAME_RECIPIENT_ACCOUNT_NUMBER)
  private String recipientAccountNumber;

  public static final String SERIALIZED_NAME_SENDER_ACCOUNT_NUMBER = "sender_account_number";
  @SerializedName(SERIALIZED_NAME_SENDER_ACCOUNT_NUMBER)
  private String senderAccountNumber;

  public static final String SERIALIZED_NAME_TRANSACTION_REMARKS = "transaction_remarks";
  @SerializedName(SERIALIZED_NAME_TRANSACTION_REMARKS)
  private String transactionRemarks;

  public static final String SERIALIZED_NAME_TRANSACTION_REASON = "transaction_reason";
  @SerializedName(SERIALIZED_NAME_TRANSACTION_REASON)
  private String transactionReason;

  public static final String SERIALIZED_NAME_TRANSACTION_ID = "transaction_id";
  @SerializedName(SERIALIZED_NAME_TRANSACTION_ID)
  private String transactionId;

  public static final String SERIALIZED_NAME_TRANSACTION_STATUS = "transaction_status";
  @SerializedName(SERIALIZED_NAME_TRANSACTION_STATUS)
  private String transactionStatus;

  public static final String SERIALIZED_NAME_DATE_CREATED = "date_created";
  @SerializedName(SERIALIZED_NAME_DATE_CREATED)
  private String dateCreated;

  public CreditSubwalletResponseEntity() {
  }

  public CreditSubwalletResponseEntity walletId(String walletId) {

    
    
    
    
    this.walletId = walletId;
    return this;
  }

   /**
   * Get walletId
   * @return walletId
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(example = "867a8cae-8073-4914-8b04-d7fd096c1006", value = "")

  public String getWalletId() {
    return walletId;
  }


  public void setWalletId(String walletId) {

    
    
    
    this.walletId = walletId;
  }


  public CreditSubwalletResponseEntity transactionAmount(Double transactionAmount) {

    
    
    
    
    this.transactionAmount = transactionAmount;
    return this;
  }

  public CreditSubwalletResponseEntity transactionAmount(Integer transactionAmount) {

    
    
    
    
    this.transactionAmount = transactionAmount.doubleValue();
    return this;
  }

   /**
   * Get transactionAmount
   * @return transactionAmount
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(example = "100", value = "")

  public Double getTransactionAmount() {
    return transactionAmount;
  }


  public void setTransactionAmount(Double transactionAmount) {

    
    
    
    this.transactionAmount = transactionAmount;
  }


  public CreditSubwalletResponseEntity transactionType(String transactionType) {

    
    
    
    
    this.transactionType = transactionType;
    return this;
  }

   /**
   * Get transactionType
   * @return transactionType
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(example = "deposit", value = "")

  public String getTransactionType() {
    return transactionType;
  }


  public void setTransactionType(String transactionType) {

    
    
    
    this.transactionType = transactionType;
  }


  public CreditSubwalletResponseEntity recipientAccountNumber(String recipientAccountNumber) {

    
    
    
    
    this.recipientAccountNumber = recipientAccountNumber;
    return this;
  }

   /**
   * Get recipientAccountNumber
   * @return recipientAccountNumber
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(example = "1004204891", value = "")

  public String getRecipientAccountNumber() {
    return recipientAccountNumber;
  }


  public void setRecipientAccountNumber(String recipientAccountNumber) {

    
    
    
    this.recipientAccountNumber = recipientAccountNumber;
  }


  public CreditSubwalletResponseEntity senderAccountNumber(String senderAccountNumber) {

    
    
    
    
    this.senderAccountNumber = senderAccountNumber;
    return this;
  }

   /**
   * Get senderAccountNumber
   * @return senderAccountNumber
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(example = "", value = "")

  public String getSenderAccountNumber() {
    return senderAccountNumber;
  }


  public void setSenderAccountNumber(String senderAccountNumber) {

    
    
    
    this.senderAccountNumber = senderAccountNumber;
  }


  public CreditSubwalletResponseEntity transactionRemarks(String transactionRemarks) {

    
    
    
    
    this.transactionRemarks = transactionRemarks;
    return this;
  }

   /**
   * Get transactionRemarks
   * @return transactionRemarks
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(example = "Dojah-wallet-credit", value = "")

  public String getTransactionRemarks() {
    return transactionRemarks;
  }


  public void setTransactionRemarks(String transactionRemarks) {

    
    
    
    this.transactionRemarks = transactionRemarks;
  }


  public CreditSubwalletResponseEntity transactionReason(String transactionReason) {

    
    
    
    
    this.transactionReason = transactionReason;
    return this;
  }

   /**
   * Get transactionReason
   * @return transactionReason
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(value = "")

  public String getTransactionReason() {
    return transactionReason;
  }


  public void setTransactionReason(String transactionReason) {

    
    
    
    this.transactionReason = transactionReason;
  }


  public CreditSubwalletResponseEntity transactionId(String transactionId) {

    
    
    
    
    this.transactionId = transactionId;
    return this;
  }

   /**
   * Get transactionId
   * @return transactionId
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(example = "Dojah-c02585e5-9a8b-4230-8c1b-11fd2869f4ce", value = "")

  public String getTransactionId() {
    return transactionId;
  }


  public void setTransactionId(String transactionId) {

    
    
    
    this.transactionId = transactionId;
  }


  public CreditSubwalletResponseEntity transactionStatus(String transactionStatus) {

    
    
    
    
    this.transactionStatus = transactionStatus;
    return this;
  }

   /**
   * Get transactionStatus
   * @return transactionStatus
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(example = "COMPLETED", value = "")

  public String getTransactionStatus() {
    return transactionStatus;
  }


  public void setTransactionStatus(String transactionStatus) {

    
    
    
    this.transactionStatus = transactionStatus;
  }


  public CreditSubwalletResponseEntity dateCreated(String dateCreated) {

    
    
    
    
    this.dateCreated = dateCreated;
    return this;
  }

   /**
   * Get dateCreated
   * @return dateCreated
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(example = "2021-07-19T11:54:01.905196Z", value = "")

  public String getDateCreated() {
    return dateCreated;
  }


  public void setDateCreated(String dateCreated) {

    
    
    
    this.dateCreated = dateCreated;
  }

  /**
   * 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<String, Object> 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 CreditSubwalletResponseEntity instance itself
   */
  public CreditSubwalletResponseEntity putAdditionalProperty(String key, Object value) {
    if (this.additionalProperties == null) {
        this.additionalProperties = new HashMap<String, Object>();
    }
    this.additionalProperties.put(key, value);
    return this;
  }

  /**
   * Return the additional (undeclared) property.
   *
   * @return a map of objects
   */
  public Map<String, Object> 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;
    }
    CreditSubwalletResponseEntity creditSubwalletResponseEntity = (CreditSubwalletResponseEntity) o;
    return Objects.equals(this.walletId, creditSubwalletResponseEntity.walletId) &&
        Objects.equals(this.transactionAmount, creditSubwalletResponseEntity.transactionAmount) &&
        Objects.equals(this.transactionType, creditSubwalletResponseEntity.transactionType) &&
        Objects.equals(this.recipientAccountNumber, creditSubwalletResponseEntity.recipientAccountNumber) &&
        Objects.equals(this.senderAccountNumber, creditSubwalletResponseEntity.senderAccountNumber) &&
        Objects.equals(this.transactionRemarks, creditSubwalletResponseEntity.transactionRemarks) &&
        Objects.equals(this.transactionReason, creditSubwalletResponseEntity.transactionReason) &&
        Objects.equals(this.transactionId, creditSubwalletResponseEntity.transactionId) &&
        Objects.equals(this.transactionStatus, creditSubwalletResponseEntity.transactionStatus) &&
        Objects.equals(this.dateCreated, creditSubwalletResponseEntity.dateCreated)&&
        Objects.equals(this.additionalProperties, creditSubwalletResponseEntity.additionalProperties);
  }

  private static <T> boolean equalsNullable(JsonNullable<T> a, JsonNullable<T> b) {
    return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get()));
  }

  @Override
  public int hashCode() {
    return Objects.hash(walletId, transactionAmount, transactionType, recipientAccountNumber, senderAccountNumber, transactionRemarks, transactionReason, transactionId, transactionStatus, dateCreated, additionalProperties);
  }

  private static <T> int hashCodeNullable(JsonNullable<T> a) {
    if (a == null) {
      return 1;
    }
    return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31;
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("class CreditSubwalletResponseEntity {\n");
    sb.append("    walletId: ").append(toIndentedString(walletId)).append("\n");
    sb.append("    transactionAmount: ").append(toIndentedString(transactionAmount)).append("\n");
    sb.append("    transactionType: ").append(toIndentedString(transactionType)).append("\n");
    sb.append("    recipientAccountNumber: ").append(toIndentedString(recipientAccountNumber)).append("\n");
    sb.append("    senderAccountNumber: ").append(toIndentedString(senderAccountNumber)).append("\n");
    sb.append("    transactionRemarks: ").append(toIndentedString(transactionRemarks)).append("\n");
    sb.append("    transactionReason: ").append(toIndentedString(transactionReason)).append("\n");
    sb.append("    transactionId: ").append(toIndentedString(transactionId)).append("\n");
    sb.append("    transactionStatus: ").append(toIndentedString(transactionStatus)).append("\n");
    sb.append("    dateCreated: ").append(toIndentedString(dateCreated)).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<String> openapiFields;
  public static HashSet<String> openapiRequiredFields;

  static {
    // a set of all properties/fields (JSON key names)
    openapiFields = new HashSet<String>();
    openapiFields.add("wallet_id");
    openapiFields.add("transaction_amount");
    openapiFields.add("transaction_type");
    openapiFields.add("recipient_account_number");
    openapiFields.add("sender_account_number");
    openapiFields.add("transaction_remarks");
    openapiFields.add("transaction_reason");
    openapiFields.add("transaction_id");
    openapiFields.add("transaction_status");
    openapiFields.add("date_created");

    // a set of required properties/fields (JSON key names)
    openapiRequiredFields = new HashSet<String>();
  }

 /**
  * 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 CreditSubwalletResponseEntity
  */
  public static void validateJsonObject(JsonObject jsonObj) throws IOException {
      if (jsonObj == null) {
        if (!CreditSubwalletResponseEntity.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
          throw new IllegalArgumentException(String.format("The required field(s) %s in CreditSubwalletResponseEntity is not found in the empty JSON string", CreditSubwalletResponseEntity.openapiRequiredFields.toString()));
        }
      }
      if ((jsonObj.get("wallet_id") != null && !jsonObj.get("wallet_id").isJsonNull()) && !jsonObj.get("wallet_id").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `wallet_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("wallet_id").toString()));
      }
      if ((jsonObj.get("transaction_type") != null && !jsonObj.get("transaction_type").isJsonNull()) && !jsonObj.get("transaction_type").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `transaction_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("transaction_type").toString()));
      }
      if ((jsonObj.get("recipient_account_number") != null && !jsonObj.get("recipient_account_number").isJsonNull()) && !jsonObj.get("recipient_account_number").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `recipient_account_number` to be a primitive type in the JSON string but got `%s`", jsonObj.get("recipient_account_number").toString()));
      }
      if ((jsonObj.get("sender_account_number") != null && !jsonObj.get("sender_account_number").isJsonNull()) && !jsonObj.get("sender_account_number").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `sender_account_number` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sender_account_number").toString()));
      }
      if ((jsonObj.get("transaction_remarks") != null && !jsonObj.get("transaction_remarks").isJsonNull()) && !jsonObj.get("transaction_remarks").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `transaction_remarks` to be a primitive type in the JSON string but got `%s`", jsonObj.get("transaction_remarks").toString()));
      }
      if (!jsonObj.get("transaction_reason").isJsonNull() && (jsonObj.get("transaction_reason") != null && !jsonObj.get("transaction_reason").isJsonNull()) && !jsonObj.get("transaction_reason").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `transaction_reason` to be a primitive type in the JSON string but got `%s`", jsonObj.get("transaction_reason").toString()));
      }
      if ((jsonObj.get("transaction_id") != null && !jsonObj.get("transaction_id").isJsonNull()) && !jsonObj.get("transaction_id").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `transaction_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("transaction_id").toString()));
      }
      if ((jsonObj.get("transaction_status") != null && !jsonObj.get("transaction_status").isJsonNull()) && !jsonObj.get("transaction_status").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `transaction_status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("transaction_status").toString()));
      }
      if ((jsonObj.get("date_created") != null && !jsonObj.get("date_created").isJsonNull()) && !jsonObj.get("date_created").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `date_created` to be a primitive type in the JSON string but got `%s`", jsonObj.get("date_created").toString()));
      }
  }

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

       return (TypeAdapter<T>) new TypeAdapter<CreditSubwalletResponseEntity>() {
           @Override
           public void write(JsonWriter out, CreditSubwalletResponseEntity value) throws IOException {
             JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
             obj.remove("additionalProperties");
             // serialize additonal properties
             if (value.getAdditionalProperties() != null) {
               for (Map.Entry<String, Object> 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 {
                   obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject());
                 }
               }
             }
             elementAdapter.write(out, obj);
           }

           @Override
           public CreditSubwalletResponseEntity read(JsonReader in) throws IOException {
             JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
             validateJsonObject(jsonObj);
             // store additional fields in the deserialized instance
             CreditSubwalletResponseEntity instance = thisAdapter.fromJsonTree(jsonObj);
             for (Map.Entry<String, JsonElement> 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 CreditSubwalletResponseEntity given an JSON string
  *
  * @param jsonString JSON string
  * @return An instance of CreditSubwalletResponseEntity
  * @throws IOException if the JSON string is invalid with respect to CreditSubwalletResponseEntity
  */
  public static CreditSubwalletResponseEntity fromJson(String jsonString) throws IOException {
    return JSON.getGson().fromJson(jsonString, CreditSubwalletResponseEntity.class);
  }

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

