java/src/main/java/com/konfigthis/dojah/client/model/GetKycPassportResponseEntity.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 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;

/**
 * GetKycPassportResponseEntity
 */
@javax.annotation.Generated(value = "Generated by https://konfigthis.com")
public class GetKycPassportResponseEntity {
  public static final String SERIALIZED_NAME_PASSPORT_NUMBER = "passport_number";
  @SerializedName(SERIALIZED_NAME_PASSPORT_NUMBER)
  private String passportNumber;

  public static final String SERIALIZED_NAME_DATE_OF_ISSUE = "date_of_issue";
  @SerializedName(SERIALIZED_NAME_DATE_OF_ISSUE)
  private String dateOfIssue;

  public static final String SERIALIZED_NAME_EXPIRY_DATE = "expiry_date";
  @SerializedName(SERIALIZED_NAME_EXPIRY_DATE)
  private String expiryDate;

  public static final String SERIALIZED_NAME_DOCUMENT_TYPE = "document_type";
  @SerializedName(SERIALIZED_NAME_DOCUMENT_TYPE)
  private String documentType;

  public static final String SERIALIZED_NAME_ISSUE_PLACE = "issue_place";
  @SerializedName(SERIALIZED_NAME_ISSUE_PLACE)
  private String issuePlace;

  public static final String SERIALIZED_NAME_SURNAME = "surname";
  @SerializedName(SERIALIZED_NAME_SURNAME)
  private String surname;

  public static final String SERIALIZED_NAME_FIRST_NAME = "first_name";
  @SerializedName(SERIALIZED_NAME_FIRST_NAME)
  private String firstName;

  public static final String SERIALIZED_NAME_OTHER_NAMES = "other_names";
  @SerializedName(SERIALIZED_NAME_OTHER_NAMES)
  private String otherNames;

  public static final String SERIALIZED_NAME_DATE_OF_BIRTH = "date_of_birth";
  @SerializedName(SERIALIZED_NAME_DATE_OF_BIRTH)
  private String dateOfBirth;

  public static final String SERIALIZED_NAME_GENDER = "gender";
  @SerializedName(SERIALIZED_NAME_GENDER)
  private String gender;

  public static final String SERIALIZED_NAME_PHOTO = "photo";
  @SerializedName(SERIALIZED_NAME_PHOTO)
  private String photo;

  public GetKycPassportResponseEntity() {
  }

  public GetKycPassportResponseEntity passportNumber(String passportNumber) {

    
    
    
    
    this.passportNumber = passportNumber;
    return this;
  }

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

  public String getPassportNumber() {
    return passportNumber;
  }


  public void setPassportNumber(String passportNumber) {

    
    
    
    this.passportNumber = passportNumber;
  }


  public GetKycPassportResponseEntity dateOfIssue(String dateOfIssue) {

    
    
    
    
    this.dateOfIssue = dateOfIssue;
    return this;
  }

   /**
   * Get dateOfIssue
   * @return dateOfIssue
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(example = "01/02/2000", value = "")

  public String getDateOfIssue() {
    return dateOfIssue;
  }


  public void setDateOfIssue(String dateOfIssue) {

    
    
    
    this.dateOfIssue = dateOfIssue;
  }


  public GetKycPassportResponseEntity expiryDate(String expiryDate) {

    
    
    
    
    this.expiryDate = expiryDate;
    return this;
  }

   /**
   * Get expiryDate
   * @return expiryDate
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(example = "01/02/2000", value = "")

  public String getExpiryDate() {
    return expiryDate;
  }


  public void setExpiryDate(String expiryDate) {

    
    
    
    this.expiryDate = expiryDate;
  }


  public GetKycPassportResponseEntity documentType(String documentType) {

    
    
    
    
    this.documentType = documentType;
    return this;
  }

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

  public String getDocumentType() {
    return documentType;
  }


  public void setDocumentType(String documentType) {

    
    
    
    this.documentType = documentType;
  }


  public GetKycPassportResponseEntity issuePlace(String issuePlace) {

    
    
    
    
    this.issuePlace = issuePlace;
    return this;
  }

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

  public String getIssuePlace() {
    return issuePlace;
  }


  public void setIssuePlace(String issuePlace) {

    
    
    
    this.issuePlace = issuePlace;
  }


  public GetKycPassportResponseEntity surname(String surname) {

    
    
    
    
    this.surname = surname;
    return this;
  }

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

  public String getSurname() {
    return surname;
  }


  public void setSurname(String surname) {

    
    
    
    this.surname = surname;
  }


  public GetKycPassportResponseEntity firstName(String firstName) {

    
    
    
    
    this.firstName = firstName;
    return this;
  }

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

  public String getFirstName() {
    return firstName;
  }


  public void setFirstName(String firstName) {

    
    
    
    this.firstName = firstName;
  }


  public GetKycPassportResponseEntity otherNames(String otherNames) {

    
    
    
    
    this.otherNames = otherNames;
    return this;
  }

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

  public String getOtherNames() {
    return otherNames;
  }


  public void setOtherNames(String otherNames) {

    
    
    
    this.otherNames = otherNames;
  }


  public GetKycPassportResponseEntity dateOfBirth(String dateOfBirth) {

    
    
    
    
    this.dateOfBirth = dateOfBirth;
    return this;
  }

   /**
   * Get dateOfBirth
   * @return dateOfBirth
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(example = "10/06/1993", value = "")

  public String getDateOfBirth() {
    return dateOfBirth;
  }


  public void setDateOfBirth(String dateOfBirth) {

    
    
    
    this.dateOfBirth = dateOfBirth;
  }


  public GetKycPassportResponseEntity gender(String gender) {

    
    
    
    
    this.gender = gender;
    return this;
  }

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

  public String getGender() {
    return gender;
  }


  public void setGender(String gender) {

    
    
    
    this.gender = gender;
  }


  public GetKycPassportResponseEntity photo(String photo) {

    
    
    
    
    this.photo = photo;
    return this;
  }

   /**
   * Get photo
   * @return photo
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(example = "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAEBAQEBAQEBA", value = "")

  public String getPhoto() {
    return photo;
  }


  public void setPhoto(String photo) {

    
    
    
    this.photo = photo;
  }

  /**
   * 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 GetKycPassportResponseEntity instance itself
   */
  public GetKycPassportResponseEntity 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;
    }
    GetKycPassportResponseEntity getKycPassportResponseEntity = (GetKycPassportResponseEntity) o;
    return Objects.equals(this.passportNumber, getKycPassportResponseEntity.passportNumber) &&
        Objects.equals(this.dateOfIssue, getKycPassportResponseEntity.dateOfIssue) &&
        Objects.equals(this.expiryDate, getKycPassportResponseEntity.expiryDate) &&
        Objects.equals(this.documentType, getKycPassportResponseEntity.documentType) &&
        Objects.equals(this.issuePlace, getKycPassportResponseEntity.issuePlace) &&
        Objects.equals(this.surname, getKycPassportResponseEntity.surname) &&
        Objects.equals(this.firstName, getKycPassportResponseEntity.firstName) &&
        Objects.equals(this.otherNames, getKycPassportResponseEntity.otherNames) &&
        Objects.equals(this.dateOfBirth, getKycPassportResponseEntity.dateOfBirth) &&
        Objects.equals(this.gender, getKycPassportResponseEntity.gender) &&
        Objects.equals(this.photo, getKycPassportResponseEntity.photo)&&
        Objects.equals(this.additionalProperties, getKycPassportResponseEntity.additionalProperties);
  }

  @Override
  public int hashCode() {
    return Objects.hash(passportNumber, dateOfIssue, expiryDate, documentType, issuePlace, surname, firstName, otherNames, dateOfBirth, gender, photo, additionalProperties);
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("class GetKycPassportResponseEntity {\n");
    sb.append("    passportNumber: ").append(toIndentedString(passportNumber)).append("\n");
    sb.append("    dateOfIssue: ").append(toIndentedString(dateOfIssue)).append("\n");
    sb.append("    expiryDate: ").append(toIndentedString(expiryDate)).append("\n");
    sb.append("    documentType: ").append(toIndentedString(documentType)).append("\n");
    sb.append("    issuePlace: ").append(toIndentedString(issuePlace)).append("\n");
    sb.append("    surname: ").append(toIndentedString(surname)).append("\n");
    sb.append("    firstName: ").append(toIndentedString(firstName)).append("\n");
    sb.append("    otherNames: ").append(toIndentedString(otherNames)).append("\n");
    sb.append("    dateOfBirth: ").append(toIndentedString(dateOfBirth)).append("\n");
    sb.append("    gender: ").append(toIndentedString(gender)).append("\n");
    sb.append("    photo: ").append(toIndentedString(photo)).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("passport_number");
    openapiFields.add("date_of_issue");
    openapiFields.add("expiry_date");
    openapiFields.add("document_type");
    openapiFields.add("issue_place");
    openapiFields.add("surname");
    openapiFields.add("first_name");
    openapiFields.add("other_names");
    openapiFields.add("date_of_birth");
    openapiFields.add("gender");
    openapiFields.add("photo");

    // 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 GetKycPassportResponseEntity
  */
  public static void validateJsonObject(JsonObject jsonObj) throws IOException {
      if (jsonObj == null) {
        if (!GetKycPassportResponseEntity.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
          throw new IllegalArgumentException(String.format("The required field(s) %s in GetKycPassportResponseEntity is not found in the empty JSON string", GetKycPassportResponseEntity.openapiRequiredFields.toString()));
        }
      }
      if ((jsonObj.get("passport_number") != null && !jsonObj.get("passport_number").isJsonNull()) && !jsonObj.get("passport_number").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `passport_number` to be a primitive type in the JSON string but got `%s`", jsonObj.get("passport_number").toString()));
      }
      if ((jsonObj.get("date_of_issue") != null && !jsonObj.get("date_of_issue").isJsonNull()) && !jsonObj.get("date_of_issue").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `date_of_issue` to be a primitive type in the JSON string but got `%s`", jsonObj.get("date_of_issue").toString()));
      }
      if ((jsonObj.get("expiry_date") != null && !jsonObj.get("expiry_date").isJsonNull()) && !jsonObj.get("expiry_date").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `expiry_date` to be a primitive type in the JSON string but got `%s`", jsonObj.get("expiry_date").toString()));
      }
      if ((jsonObj.get("document_type") != null && !jsonObj.get("document_type").isJsonNull()) && !jsonObj.get("document_type").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `document_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("document_type").toString()));
      }
      if ((jsonObj.get("issue_place") != null && !jsonObj.get("issue_place").isJsonNull()) && !jsonObj.get("issue_place").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `issue_place` to be a primitive type in the JSON string but got `%s`", jsonObj.get("issue_place").toString()));
      }
      if ((jsonObj.get("surname") != null && !jsonObj.get("surname").isJsonNull()) && !jsonObj.get("surname").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `surname` to be a primitive type in the JSON string but got `%s`", jsonObj.get("surname").toString()));
      }
      if ((jsonObj.get("first_name") != null && !jsonObj.get("first_name").isJsonNull()) && !jsonObj.get("first_name").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `first_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("first_name").toString()));
      }
      if ((jsonObj.get("other_names") != null && !jsonObj.get("other_names").isJsonNull()) && !jsonObj.get("other_names").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `other_names` to be a primitive type in the JSON string but got `%s`", jsonObj.get("other_names").toString()));
      }
      if ((jsonObj.get("date_of_birth") != null && !jsonObj.get("date_of_birth").isJsonNull()) && !jsonObj.get("date_of_birth").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `date_of_birth` to be a primitive type in the JSON string but got `%s`", jsonObj.get("date_of_birth").toString()));
      }
      if ((jsonObj.get("gender") != null && !jsonObj.get("gender").isJsonNull()) && !jsonObj.get("gender").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `gender` to be a primitive type in the JSON string but got `%s`", jsonObj.get("gender").toString()));
      }
      if ((jsonObj.get("photo") != null && !jsonObj.get("photo").isJsonNull()) && !jsonObj.get("photo").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `photo` to be a primitive type in the JSON string but got `%s`", jsonObj.get("photo").toString()));
      }
  }

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

       return (TypeAdapter<T>) new TypeAdapter<GetKycPassportResponseEntity>() {
           @Override
           public void write(JsonWriter out, GetKycPassportResponseEntity 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 GetKycPassportResponseEntity read(JsonReader in) throws IOException {
             JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
             validateJsonObject(jsonObj);
             // store additional fields in the deserialized instance
             GetKycPassportResponseEntity 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 GetKycPassportResponseEntity given an JSON string
  *
  * @param jsonString JSON string
  * @return An instance of GetKycPassportResponseEntity
  * @throws IOException if the JSON string is invalid with respect to GetKycPassportResponseEntity
  */
  public static GetKycPassportResponseEntity fromJson(String jsonString) throws IOException {
    return JSON.getGson().fromJson(jsonString, GetKycPassportResponseEntity.class);
  }

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

