com.zuora.model.ContactResponse Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of zuora-sdk-java Show documentation
Show all versions of zuora-sdk-java Show documentation
The SDK of JAVA language for Zuora pricing system
/*
* Zuora API Reference
* REST API reference for the Zuora Billing, Payments, and Central Platform! Check out the [REST API Overview](https://www.zuora.com/developer/api-references/api/overview/).
*
* The version of the OpenAPI document: 2024-05-20
* 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.zuora.model;
import java.util.Objects;
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 com.zuora.model.FailedReason;
import com.zuora.model.PhoneType;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
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 com.google.gson.TypeAdapter;
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.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.zuora.JSON;
/**
* Container for response about the contact.
*/
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.6.0")
public class ContactResponse {
public static final String SERIALIZED_NAME_PROCESS_ID = "processId";
@SerializedName(SERIALIZED_NAME_PROCESS_ID)
private String processId;
public static final String SERIALIZED_NAME_REQUEST_ID = "requestId";
@SerializedName(SERIALIZED_NAME_REQUEST_ID)
private String requestId;
public static final String SERIALIZED_NAME_REASONS = "reasons";
@SerializedName(SERIALIZED_NAME_REASONS)
private List reasons;
public static final String SERIALIZED_NAME_SUCCESS = "success";
@SerializedName(SERIALIZED_NAME_SUCCESS)
private Boolean success;
public static final String SERIALIZED_NAME_ID = "id";
@SerializedName(SERIALIZED_NAME_ID)
private String id;
public static final String SERIALIZED_NAME_ACCOUNT_ID = "accountId";
@SerializedName(SERIALIZED_NAME_ACCOUNT_ID)
private String accountId;
public static final String SERIALIZED_NAME_ACCOUNT_NUMBER = "accountNumber";
@SerializedName(SERIALIZED_NAME_ACCOUNT_NUMBER)
private String accountNumber;
public static final String SERIALIZED_NAME_ADDRESS1 = "address1";
@SerializedName(SERIALIZED_NAME_ADDRESS1)
private String address1;
public static final String SERIALIZED_NAME_ADDRESS2 = "address2";
@SerializedName(SERIALIZED_NAME_ADDRESS2)
private String address2;
public static final String SERIALIZED_NAME_CITY = "city";
@SerializedName(SERIALIZED_NAME_CITY)
private String city;
public static final String SERIALIZED_NAME_CONTACT_DESCRIPTION = "contactDescription";
@SerializedName(SERIALIZED_NAME_CONTACT_DESCRIPTION)
private String contactDescription;
public static final String SERIALIZED_NAME_COUNTRY = "country";
@SerializedName(SERIALIZED_NAME_COUNTRY)
private String country;
public static final String SERIALIZED_NAME_COUNTY = "county";
@SerializedName(SERIALIZED_NAME_COUNTY)
private String county;
public static final String SERIALIZED_NAME_FAX = "fax";
@SerializedName(SERIALIZED_NAME_FAX)
private String fax;
public static final String SERIALIZED_NAME_FIRST_NAME = "firstName";
@SerializedName(SERIALIZED_NAME_FIRST_NAME)
private String firstName;
public static final String SERIALIZED_NAME_HOME_PHONE = "homePhone";
@SerializedName(SERIALIZED_NAME_HOME_PHONE)
private String homePhone;
public static final String SERIALIZED_NAME_LAST_NAME = "lastName";
@SerializedName(SERIALIZED_NAME_LAST_NAME)
private String lastName;
public static final String SERIALIZED_NAME_MOBILE_PHONE = "mobilePhone";
@SerializedName(SERIALIZED_NAME_MOBILE_PHONE)
private String mobilePhone;
public static final String SERIALIZED_NAME_NICKNAME = "nickname";
@SerializedName(SERIALIZED_NAME_NICKNAME)
private String nickname;
public static final String SERIALIZED_NAME_OTHER_PHONE = "otherPhone";
@SerializedName(SERIALIZED_NAME_OTHER_PHONE)
private String otherPhone;
public static final String SERIALIZED_NAME_OTHER_PHONE_TYPE = "otherPhoneType";
@SerializedName(SERIALIZED_NAME_OTHER_PHONE_TYPE)
private PhoneType otherPhoneType;
public static final String SERIALIZED_NAME_PERSONAL_EMAIL = "personalEmail";
@SerializedName(SERIALIZED_NAME_PERSONAL_EMAIL)
private String personalEmail;
public static final String SERIALIZED_NAME_STATE = "state";
@SerializedName(SERIALIZED_NAME_STATE)
private String state;
public static final String SERIALIZED_NAME_TAX_REGION = "taxRegion";
@SerializedName(SERIALIZED_NAME_TAX_REGION)
private String taxRegion;
public static final String SERIALIZED_NAME_WORK_EMAIL = "workEmail";
@SerializedName(SERIALIZED_NAME_WORK_EMAIL)
private String workEmail;
public static final String SERIALIZED_NAME_WORK_PHONE = "workPhone";
@SerializedName(SERIALIZED_NAME_WORK_PHONE)
private String workPhone;
public static final String SERIALIZED_NAME_ZIP_CODE = "zipCode";
@SerializedName(SERIALIZED_NAME_ZIP_CODE)
private String zipCode;
public static final String SERIALIZED_NAME_POSTAL_CODE = "postalCode";
@SerializedName(SERIALIZED_NAME_POSTAL_CODE)
private String postalCode;
public static final String SERIALIZED_NAME_AS_BILL_TO = "asBillTo";
@SerializedName(SERIALIZED_NAME_AS_BILL_TO)
private Boolean asBillTo;
public static final String SERIALIZED_NAME_AS_SOLD_TO = "asSoldTo";
@SerializedName(SERIALIZED_NAME_AS_SOLD_TO)
private Boolean asSoldTo;
public static final String SERIALIZED_NAME_AS_SHIP_TO = "asShipTo";
@SerializedName(SERIALIZED_NAME_AS_SHIP_TO)
private Boolean asShipTo;
public ContactResponse() {
}
public ContactResponse processId(String processId) {
this.processId = processId;
return this;
}
/**
* The Id of the process that handle the operation.
* @return processId
*/
@javax.annotation.Nullable
public String getProcessId() {
return processId;
}
public void setProcessId(String processId) {
this.processId = processId;
}
public ContactResponse requestId(String requestId) {
this.requestId = requestId;
return this;
}
/**
* Unique request identifier. If you need to contact us about a specific request, providing the request identifier will ensure the fastest possible resolution.
* @return requestId
*/
@javax.annotation.Nullable
public String getRequestId() {
return requestId;
}
public void setRequestId(String requestId) {
this.requestId = requestId;
}
public ContactResponse reasons(List reasons) {
this.reasons = reasons;
return this;
}
public ContactResponse addReasonsItem(FailedReason reasonsItem) {
if (this.reasons == null) {
this.reasons = new ArrayList<>();
}
this.reasons.add(reasonsItem);
return this;
}
/**
* Get reasons
* @return reasons
*/
@javax.annotation.Nullable
public List getReasons() {
return reasons;
}
public void setReasons(List reasons) {
this.reasons = reasons;
}
public ContactResponse success(Boolean success) {
this.success = success;
return this;
}
/**
* Returns `true` if the request was processed successfully.
* @return success
*/
@javax.annotation.Nullable
public Boolean getSuccess() {
return success;
}
public void setSuccess(Boolean success) {
this.success = success;
}
public ContactResponse id(String id) {
this.id = id;
return this;
}
/**
* The ID of the contact.
* @return id
*/
@javax.annotation.Nullable
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public ContactResponse accountId(String accountId) {
this.accountId = accountId;
return this;
}
/**
* The ID of the account associated with the contact.
* @return accountId
*/
@javax.annotation.Nullable
public String getAccountId() {
return accountId;
}
public void setAccountId(String accountId) {
this.accountId = accountId;
}
public ContactResponse accountNumber(String accountNumber) {
this.accountNumber = accountNumber;
return this;
}
/**
* The number of the customer account associated with the contact.
* @return accountNumber
*/
@javax.annotation.Nullable
public String getAccountNumber() {
return accountNumber;
}
public void setAccountNumber(String accountNumber) {
this.accountNumber = accountNumber;
}
public ContactResponse address1(String address1) {
this.address1 = address1;
return this;
}
/**
* The first line of the contact's address, which is often a street address or business name.
* @return address1
*/
@javax.annotation.Nullable
public String getAddress1() {
return address1;
}
public void setAddress1(String address1) {
this.address1 = address1;
}
public ContactResponse address2(String address2) {
this.address2 = address2;
return this;
}
/**
* The second line of the contact's address.
* @return address2
*/
@javax.annotation.Nullable
public String getAddress2() {
return address2;
}
public void setAddress2(String address2) {
this.address2 = address2;
}
public ContactResponse city(String city) {
this.city = city;
return this;
}
/**
* The city of the contact's address.
* @return city
*/
@javax.annotation.Nullable
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public ContactResponse contactDescription(String contactDescription) {
this.contactDescription = contactDescription;
return this;
}
/**
* A description for the contact.
* @return contactDescription
*/
@javax.annotation.Nullable
public String getContactDescription() {
return contactDescription;
}
public void setContactDescription(String contactDescription) {
this.contactDescription = contactDescription;
}
public ContactResponse country(String country) {
this.country = country;
return this;
}
/**
* The country of the contact's address.
* @return country
*/
@javax.annotation.Nullable
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public ContactResponse county(String county) {
this.county = county;
return this;
}
/**
* The county. May optionally be used by Zuora Tax to calculate county tax.
* @return county
*/
@javax.annotation.Nullable
public String getCounty() {
return county;
}
public void setCounty(String county) {
this.county = county;
}
public ContactResponse fax(String fax) {
this.fax = fax;
return this;
}
/**
* The contact's fax number.
* @return fax
*/
@javax.annotation.Nullable
public String getFax() {
return fax;
}
public void setFax(String fax) {
this.fax = fax;
}
public ContactResponse firstName(String firstName) {
this.firstName = firstName;
return this;
}
/**
* The contact's first name.
* @return firstName
*/
@javax.annotation.Nullable
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public ContactResponse homePhone(String homePhone) {
this.homePhone = homePhone;
return this;
}
/**
* The contact's home phone number.
* @return homePhone
*/
@javax.annotation.Nullable
public String getHomePhone() {
return homePhone;
}
public void setHomePhone(String homePhone) {
this.homePhone = homePhone;
}
public ContactResponse lastName(String lastName) {
this.lastName = lastName;
return this;
}
/**
* The contact's last name.
* @return lastName
*/
@javax.annotation.Nullable
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public ContactResponse mobilePhone(String mobilePhone) {
this.mobilePhone = mobilePhone;
return this;
}
/**
* The mobile phone number of the contact.
* @return mobilePhone
*/
@javax.annotation.Nullable
public String getMobilePhone() {
return mobilePhone;
}
public void setMobilePhone(String mobilePhone) {
this.mobilePhone = mobilePhone;
}
public ContactResponse nickname(String nickname) {
this.nickname = nickname;
return this;
}
/**
* A nickname for the contact.
* @return nickname
*/
@javax.annotation.Nullable
public String getNickname() {
return nickname;
}
public void setNickname(String nickname) {
this.nickname = nickname;
}
public ContactResponse otherPhone(String otherPhone) {
this.otherPhone = otherPhone;
return this;
}
/**
* An additional phone number for the contact.
* @return otherPhone
*/
@javax.annotation.Nullable
public String getOtherPhone() {
return otherPhone;
}
public void setOtherPhone(String otherPhone) {
this.otherPhone = otherPhone;
}
public ContactResponse otherPhoneType(PhoneType otherPhoneType) {
this.otherPhoneType = otherPhoneType;
return this;
}
/**
* Get otherPhoneType
* @return otherPhoneType
*/
@javax.annotation.Nullable
public PhoneType getOtherPhoneType() {
return otherPhoneType;
}
public void setOtherPhoneType(PhoneType otherPhoneType) {
this.otherPhoneType = otherPhoneType;
}
public ContactResponse personalEmail(String personalEmail) {
this.personalEmail = personalEmail;
return this;
}
/**
* The contact's personal email address.
* @return personalEmail
*/
@javax.annotation.Nullable
public String getPersonalEmail() {
return personalEmail;
}
public void setPersonalEmail(String personalEmail) {
this.personalEmail = personalEmail;
}
public ContactResponse state(String state) {
this.state = state;
return this;
}
/**
* The state or province of the contact's address.
* @return state
*/
@javax.annotation.Nullable
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public ContactResponse taxRegion(String taxRegion) {
this.taxRegion = taxRegion;
return this;
}
/**
* If using Zuora Tax, a region string as optionally defined in your tax rules. Not required.
* @return taxRegion
*/
@javax.annotation.Nullable
public String getTaxRegion() {
return taxRegion;
}
public void setTaxRegion(String taxRegion) {
this.taxRegion = taxRegion;
}
public ContactResponse workEmail(String workEmail) {
this.workEmail = workEmail;
return this;
}
/**
* The contact's business email address.
* @return workEmail
*/
@javax.annotation.Nullable
public String getWorkEmail() {
return workEmail;
}
public void setWorkEmail(String workEmail) {
this.workEmail = workEmail;
}
public ContactResponse workPhone(String workPhone) {
this.workPhone = workPhone;
return this;
}
/**
* The contact's business phone number.
* @return workPhone
*/
@javax.annotation.Nullable
public String getWorkPhone() {
return workPhone;
}
public void setWorkPhone(String workPhone) {
this.workPhone = workPhone;
}
public ContactResponse zipCode(String zipCode) {
this.zipCode = zipCode;
return this;
}
/**
* The zip code for the contact's address.
* @return zipCode
*/
@javax.annotation.Nullable
public String getZipCode() {
return zipCode;
}
public void setZipCode(String zipCode) {
this.zipCode = zipCode;
}
public ContactResponse postalCode(String postalCode) {
this.postalCode = postalCode;
return this;
}
/**
* Same as zipCode, used in get subscription billto, soldto contact info.
* @return postalCode
*/
@javax.annotation.Nullable
public String getPostalCode() {
return postalCode;
}
public void setPostalCode(String postalCode) {
this.postalCode = postalCode;
}
public ContactResponse asBillTo(Boolean asBillTo) {
this.asBillTo = asBillTo;
return this;
}
/**
* Indicates the contact can as a bill to. Need Permission 'ShipToContactSupport'
* @return asBillTo
*/
@javax.annotation.Nullable
public Boolean getAsBillTo() {
return asBillTo;
}
public void setAsBillTo(Boolean asBillTo) {
this.asBillTo = asBillTo;
}
public ContactResponse asSoldTo(Boolean asSoldTo) {
this.asSoldTo = asSoldTo;
return this;
}
/**
* Indicates the contact can as a sold to. Need Permission 'ShipToContactSupport'
* @return asSoldTo
*/
@javax.annotation.Nullable
public Boolean getAsSoldTo() {
return asSoldTo;
}
public void setAsSoldTo(Boolean asSoldTo) {
this.asSoldTo = asSoldTo;
}
public ContactResponse asShipTo(Boolean asShipTo) {
this.asShipTo = asShipTo;
return this;
}
/**
* Indicates the contact can as a ship to. Need Permission 'ShipToContactSupport'
* @return asShipTo
*/
@javax.annotation.Nullable
public Boolean getAsShipTo() {
return asShipTo;
}
public void setAsShipTo(Boolean asShipTo) {
this.asShipTo = asShipTo;
}
/**
* 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 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 ContactResponse instance itself
*/
public ContactResponse putAdditionalProperty(String key, Object value) {
if (this.additionalProperties == null) {
this.additionalProperties = new HashMap();
}
this.additionalProperties.put(key, value);
return this;
}
/**
* Return the additional (undeclared) property.
*
* @return a map of objects
*/
public Map 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;
}
ContactResponse contactResponse = (ContactResponse) o;
return Objects.equals(this.processId, contactResponse.processId) &&
Objects.equals(this.requestId, contactResponse.requestId) &&
Objects.equals(this.reasons, contactResponse.reasons) &&
Objects.equals(this.success, contactResponse.success) &&
Objects.equals(this.id, contactResponse.id) &&
Objects.equals(this.accountId, contactResponse.accountId) &&
Objects.equals(this.accountNumber, contactResponse.accountNumber) &&
Objects.equals(this.address1, contactResponse.address1) &&
Objects.equals(this.address2, contactResponse.address2) &&
Objects.equals(this.city, contactResponse.city) &&
Objects.equals(this.contactDescription, contactResponse.contactDescription) &&
Objects.equals(this.country, contactResponse.country) &&
Objects.equals(this.county, contactResponse.county) &&
Objects.equals(this.fax, contactResponse.fax) &&
Objects.equals(this.firstName, contactResponse.firstName) &&
Objects.equals(this.homePhone, contactResponse.homePhone) &&
Objects.equals(this.lastName, contactResponse.lastName) &&
Objects.equals(this.mobilePhone, contactResponse.mobilePhone) &&
Objects.equals(this.nickname, contactResponse.nickname) &&
Objects.equals(this.otherPhone, contactResponse.otherPhone) &&
Objects.equals(this.otherPhoneType, contactResponse.otherPhoneType) &&
Objects.equals(this.personalEmail, contactResponse.personalEmail) &&
Objects.equals(this.state, contactResponse.state) &&
Objects.equals(this.taxRegion, contactResponse.taxRegion) &&
Objects.equals(this.workEmail, contactResponse.workEmail) &&
Objects.equals(this.workPhone, contactResponse.workPhone) &&
Objects.equals(this.zipCode, contactResponse.zipCode) &&
Objects.equals(this.postalCode, contactResponse.postalCode) &&
Objects.equals(this.asBillTo, contactResponse.asBillTo) &&
Objects.equals(this.asSoldTo, contactResponse.asSoldTo) &&
Objects.equals(this.asShipTo, contactResponse.asShipTo)&&
Objects.equals(this.additionalProperties, contactResponse.additionalProperties);
}
@Override
public int hashCode() {
return Objects.hash(processId, requestId, reasons, success, id, accountId, accountNumber, address1, address2, city, contactDescription, country, county, fax, firstName, homePhone, lastName, mobilePhone, nickname, otherPhone, otherPhoneType, personalEmail, state, taxRegion, workEmail, workPhone, zipCode, postalCode, asBillTo, asSoldTo, asShipTo, additionalProperties);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class ContactResponse {\n");
sb.append(" processId: ").append(toIndentedString(processId)).append("\n");
sb.append(" requestId: ").append(toIndentedString(requestId)).append("\n");
sb.append(" reasons: ").append(toIndentedString(reasons)).append("\n");
sb.append(" success: ").append(toIndentedString(success)).append("\n");
sb.append(" id: ").append(toIndentedString(id)).append("\n");
sb.append(" accountId: ").append(toIndentedString(accountId)).append("\n");
sb.append(" accountNumber: ").append(toIndentedString(accountNumber)).append("\n");
sb.append(" address1: ").append(toIndentedString(address1)).append("\n");
sb.append(" address2: ").append(toIndentedString(address2)).append("\n");
sb.append(" city: ").append(toIndentedString(city)).append("\n");
sb.append(" contactDescription: ").append(toIndentedString(contactDescription)).append("\n");
sb.append(" country: ").append(toIndentedString(country)).append("\n");
sb.append(" county: ").append(toIndentedString(county)).append("\n");
sb.append(" fax: ").append(toIndentedString(fax)).append("\n");
sb.append(" firstName: ").append(toIndentedString(firstName)).append("\n");
sb.append(" homePhone: ").append(toIndentedString(homePhone)).append("\n");
sb.append(" lastName: ").append(toIndentedString(lastName)).append("\n");
sb.append(" mobilePhone: ").append(toIndentedString(mobilePhone)).append("\n");
sb.append(" nickname: ").append(toIndentedString(nickname)).append("\n");
sb.append(" otherPhone: ").append(toIndentedString(otherPhone)).append("\n");
sb.append(" otherPhoneType: ").append(toIndentedString(otherPhoneType)).append("\n");
sb.append(" personalEmail: ").append(toIndentedString(personalEmail)).append("\n");
sb.append(" state: ").append(toIndentedString(state)).append("\n");
sb.append(" taxRegion: ").append(toIndentedString(taxRegion)).append("\n");
sb.append(" workEmail: ").append(toIndentedString(workEmail)).append("\n");
sb.append(" workPhone: ").append(toIndentedString(workPhone)).append("\n");
sb.append(" zipCode: ").append(toIndentedString(zipCode)).append("\n");
sb.append(" postalCode: ").append(toIndentedString(postalCode)).append("\n");
sb.append(" asBillTo: ").append(toIndentedString(asBillTo)).append("\n");
sb.append(" asSoldTo: ").append(toIndentedString(asSoldTo)).append("\n");
sb.append(" asShipTo: ").append(toIndentedString(asShipTo)).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 openapiFields;
public static HashSet openapiRequiredFields;
static {
// a set of all properties/fields (JSON key names)
openapiFields = new HashSet();
openapiFields.add("processId");
openapiFields.add("requestId");
openapiFields.add("reasons");
openapiFields.add("success");
openapiFields.add("id");
openapiFields.add("accountId");
openapiFields.add("accountNumber");
openapiFields.add("address1");
openapiFields.add("address2");
openapiFields.add("city");
openapiFields.add("contactDescription");
openapiFields.add("country");
openapiFields.add("county");
openapiFields.add("fax");
openapiFields.add("firstName");
openapiFields.add("homePhone");
openapiFields.add("lastName");
openapiFields.add("mobilePhone");
openapiFields.add("nickname");
openapiFields.add("otherPhone");
openapiFields.add("otherPhoneType");
openapiFields.add("personalEmail");
openapiFields.add("state");
openapiFields.add("taxRegion");
openapiFields.add("workEmail");
openapiFields.add("workPhone");
openapiFields.add("zipCode");
openapiFields.add("postalCode");
openapiFields.add("asBillTo");
openapiFields.add("asSoldTo");
openapiFields.add("asShipTo");
// a set of required properties/fields (JSON key names)
openapiRequiredFields = new HashSet();
}
/**
* Validates the JSON Element and throws an exception if issues found
*
* @param jsonElement JSON Element
* @throws IOException if the JSON Element is invalid with respect to ContactResponse
*/
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
if (jsonElement == null) {
if (!ContactResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in ContactResponse is not found in the empty JSON string", ContactResponse.openapiRequiredFields.toString()));
}
}
JsonObject jsonObj = jsonElement.getAsJsonObject();
if ((jsonObj.get("processId") != null && !jsonObj.get("processId").isJsonNull()) && !jsonObj.get("processId").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `processId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("processId").toString()));
}
if ((jsonObj.get("requestId") != null && !jsonObj.get("requestId").isJsonNull()) && !jsonObj.get("requestId").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `requestId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("requestId").toString()));
}
if (jsonObj.get("reasons") != null && !jsonObj.get("reasons").isJsonNull()) {
JsonArray jsonArrayreasons = jsonObj.getAsJsonArray("reasons");
if (jsonArrayreasons != null) {
// ensure the json data is an array
if (!jsonObj.get("reasons").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `reasons` to be an array in the JSON string but got `%s`", jsonObj.get("reasons").toString()));
}
// validate the optional field `reasons` (array)
for (int i = 0; i < jsonArrayreasons.size(); i++) {
FailedReason.validateJsonElement(jsonArrayreasons.get(i));
};
}
}
if ((jsonObj.get("id") != null && !jsonObj.get("id").isJsonNull()) && !jsonObj.get("id").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString()));
}
if ((jsonObj.get("accountId") != null && !jsonObj.get("accountId").isJsonNull()) && !jsonObj.get("accountId").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `accountId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("accountId").toString()));
}
if ((jsonObj.get("accountNumber") != null && !jsonObj.get("accountNumber").isJsonNull()) && !jsonObj.get("accountNumber").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `accountNumber` to be a primitive type in the JSON string but got `%s`", jsonObj.get("accountNumber").toString()));
}
if ((jsonObj.get("address1") != null && !jsonObj.get("address1").isJsonNull()) && !jsonObj.get("address1").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `address1` to be a primitive type in the JSON string but got `%s`", jsonObj.get("address1").toString()));
}
if ((jsonObj.get("address2") != null && !jsonObj.get("address2").isJsonNull()) && !jsonObj.get("address2").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `address2` to be a primitive type in the JSON string but got `%s`", jsonObj.get("address2").toString()));
}
if ((jsonObj.get("city") != null && !jsonObj.get("city").isJsonNull()) && !jsonObj.get("city").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `city` to be a primitive type in the JSON string but got `%s`", jsonObj.get("city").toString()));
}
if ((jsonObj.get("contactDescription") != null && !jsonObj.get("contactDescription").isJsonNull()) && !jsonObj.get("contactDescription").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `contactDescription` to be a primitive type in the JSON string but got `%s`", jsonObj.get("contactDescription").toString()));
}
if ((jsonObj.get("country") != null && !jsonObj.get("country").isJsonNull()) && !jsonObj.get("country").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `country` to be a primitive type in the JSON string but got `%s`", jsonObj.get("country").toString()));
}
if ((jsonObj.get("county") != null && !jsonObj.get("county").isJsonNull()) && !jsonObj.get("county").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `county` to be a primitive type in the JSON string but got `%s`", jsonObj.get("county").toString()));
}
if ((jsonObj.get("fax") != null && !jsonObj.get("fax").isJsonNull()) && !jsonObj.get("fax").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `fax` to be a primitive type in the JSON string but got `%s`", jsonObj.get("fax").toString()));
}
if ((jsonObj.get("firstName") != null && !jsonObj.get("firstName").isJsonNull()) && !jsonObj.get("firstName").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `firstName` to be a primitive type in the JSON string but got `%s`", jsonObj.get("firstName").toString()));
}
if ((jsonObj.get("homePhone") != null && !jsonObj.get("homePhone").isJsonNull()) && !jsonObj.get("homePhone").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `homePhone` to be a primitive type in the JSON string but got `%s`", jsonObj.get("homePhone").toString()));
}
if ((jsonObj.get("lastName") != null && !jsonObj.get("lastName").isJsonNull()) && !jsonObj.get("lastName").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `lastName` to be a primitive type in the JSON string but got `%s`", jsonObj.get("lastName").toString()));
}
if ((jsonObj.get("mobilePhone") != null && !jsonObj.get("mobilePhone").isJsonNull()) && !jsonObj.get("mobilePhone").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `mobilePhone` to be a primitive type in the JSON string but got `%s`", jsonObj.get("mobilePhone").toString()));
}
if ((jsonObj.get("nickname") != null && !jsonObj.get("nickname").isJsonNull()) && !jsonObj.get("nickname").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `nickname` to be a primitive type in the JSON string but got `%s`", jsonObj.get("nickname").toString()));
}
if ((jsonObj.get("otherPhone") != null && !jsonObj.get("otherPhone").isJsonNull()) && !jsonObj.get("otherPhone").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `otherPhone` to be a primitive type in the JSON string but got `%s`", jsonObj.get("otherPhone").toString()));
}
if ((jsonObj.get("otherPhoneType") != null && !jsonObj.get("otherPhoneType").isJsonNull()) && !jsonObj.get("otherPhoneType").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `otherPhoneType` to be a primitive type in the JSON string but got `%s`", jsonObj.get("otherPhoneType").toString()));
}
// validate the optional field `otherPhoneType`
if (jsonObj.get("otherPhoneType") != null && !jsonObj.get("otherPhoneType").isJsonNull()) {
PhoneType.validateJsonElement(jsonObj.get("otherPhoneType"));
}
if ((jsonObj.get("personalEmail") != null && !jsonObj.get("personalEmail").isJsonNull()) && !jsonObj.get("personalEmail").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `personalEmail` to be a primitive type in the JSON string but got `%s`", jsonObj.get("personalEmail").toString()));
}
if ((jsonObj.get("state") != null && !jsonObj.get("state").isJsonNull()) && !jsonObj.get("state").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `state` to be a primitive type in the JSON string but got `%s`", jsonObj.get("state").toString()));
}
if ((jsonObj.get("taxRegion") != null && !jsonObj.get("taxRegion").isJsonNull()) && !jsonObj.get("taxRegion").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `taxRegion` to be a primitive type in the JSON string but got `%s`", jsonObj.get("taxRegion").toString()));
}
if ((jsonObj.get("workEmail") != null && !jsonObj.get("workEmail").isJsonNull()) && !jsonObj.get("workEmail").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `workEmail` to be a primitive type in the JSON string but got `%s`", jsonObj.get("workEmail").toString()));
}
if ((jsonObj.get("workPhone") != null && !jsonObj.get("workPhone").isJsonNull()) && !jsonObj.get("workPhone").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `workPhone` to be a primitive type in the JSON string but got `%s`", jsonObj.get("workPhone").toString()));
}
if ((jsonObj.get("zipCode") != null && !jsonObj.get("zipCode").isJsonNull()) && !jsonObj.get("zipCode").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `zipCode` to be a primitive type in the JSON string but got `%s`", jsonObj.get("zipCode").toString()));
}
if ((jsonObj.get("postalCode") != null && !jsonObj.get("postalCode").isJsonNull()) && !jsonObj.get("postalCode").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `postalCode` to be a primitive type in the JSON string but got `%s`", jsonObj.get("postalCode").toString()));
}
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@SuppressWarnings("unchecked")
@Override
public TypeAdapter create(Gson gson, TypeToken type) {
if (!ContactResponse.class.isAssignableFrom(type.getRawType())) {
return null; // this class only serializes 'ContactResponse' and its subtypes
}
final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
final TypeAdapter thisAdapter
= gson.getDelegateAdapter(this, TypeToken.get(ContactResponse.class));
return (TypeAdapter) new TypeAdapter() {
@Override
public void write(JsonWriter out, ContactResponse value) throws IOException {
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
obj.remove("additionalProperties");
// support null values
out.beginObject();
Iterator iterator = obj.entrySet().iterator();
while(iterator.hasNext()) {
Map.Entry e = (Map.Entry) iterator.next();
out.name((String)e.getKey());
elementAdapter.write(out, e.getValue());
}
// end
// serialize additional properties
if (value.getAdditionalProperties() != null) {
// support null values
boolean oldSerializeNulls = out.getSerializeNulls();
out.setSerializeNulls(true); //force serialize
// end
for (Map.Entry 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 if (entry.getValue() == null)
obj.add(entry.getKey(), null);
else {
JsonElement jsonElement = gson.toJsonTree(entry.getValue());
if (jsonElement.isJsonArray()) {
obj.add(entry.getKey(), jsonElement.getAsJsonArray());
} else {
obj.add(entry.getKey(), jsonElement.getAsJsonObject());
}
}
out.name((String)entry.getKey());
elementAdapter.write(out, obj.get(entry.getKey()));
}
out.setSerializeNulls(oldSerializeNulls); //restore
}
out.endObject();
}
@Override
public ContactResponse read(JsonReader in) throws IOException {
JsonElement jsonElement = elementAdapter.read(in);
validateJsonElement(jsonElement);
JsonObject jsonObj = jsonElement.getAsJsonObject();
// store additional fields in the deserialized instance
ContactResponse instance = thisAdapter.fromJsonTree(jsonObj);
for (Map.Entry 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 ContactResponse given an JSON string
*
* @param jsonString JSON string
* @return An instance of ContactResponse
* @throws IOException if the JSON string is invalid with respect to ContactResponse
*/
public static ContactResponse fromJson(String jsonString) throws IOException {
return JSON.getGson().fromJson(jsonString, ContactResponse.class);
}
/**
* Convert an instance of ContactResponse to an JSON string
*
* @return JSON string
*/
public String toJson() {
return JSON.getGson().toJson(this);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy