com.zuora.model.CreateTaxationItemForInvoiceRequest 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.TaxItemsFinanceInformation;
import com.zuora.model.TaxMode;
import com.zuora.model.TaxRateType;
import java.io.IOException;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.Arrays;
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;
/**
* CreateTaxationItemForInvoiceRequest
*/
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.6.0")
public class CreateTaxationItemForInvoiceRequest {
public static final String SERIALIZED_NAME_EXEMPT_AMOUNT = "exemptAmount";
@SerializedName(SERIALIZED_NAME_EXEMPT_AMOUNT)
private BigDecimal exemptAmount;
public static final String SERIALIZED_NAME_FINANCE_INFORMATION = "financeInformation";
@SerializedName(SERIALIZED_NAME_FINANCE_INFORMATION)
private TaxItemsFinanceInformation financeInformation;
public static final String SERIALIZED_NAME_INVOICE_ITEM_ID = "invoiceItemId";
@SerializedName(SERIALIZED_NAME_INVOICE_ITEM_ID)
private String invoiceItemId;
public static final String SERIALIZED_NAME_JURISDICTION = "jurisdiction";
@SerializedName(SERIALIZED_NAME_JURISDICTION)
private String jurisdiction;
public static final String SERIALIZED_NAME_LOCATION_CODE = "locationCode";
@SerializedName(SERIALIZED_NAME_LOCATION_CODE)
private String locationCode;
public static final String SERIALIZED_NAME_NAME = "name";
@SerializedName(SERIALIZED_NAME_NAME)
private String name;
public static final String SERIALIZED_NAME_TAX_AMOUNT = "taxAmount";
@SerializedName(SERIALIZED_NAME_TAX_AMOUNT)
private BigDecimal taxAmount;
public static final String SERIALIZED_NAME_APPLICABLE_TAX_UN_ROUNDED = "applicableTaxUnRounded";
@SerializedName(SERIALIZED_NAME_APPLICABLE_TAX_UN_ROUNDED)
private BigDecimal applicableTaxUnRounded;
public static final String SERIALIZED_NAME_COUNTRY = "country";
@SerializedName(SERIALIZED_NAME_COUNTRY)
private String country;
public static final String SERIALIZED_NAME_TAX_CODE = "taxCode";
@SerializedName(SERIALIZED_NAME_TAX_CODE)
private String taxCode;
public static final String SERIALIZED_NAME_TAX_CODE_DESCRIPTION = "taxCodeDescription";
@SerializedName(SERIALIZED_NAME_TAX_CODE_DESCRIPTION)
private String taxCodeDescription;
public static final String SERIALIZED_NAME_TAX_DATE = "taxDate";
@SerializedName(SERIALIZED_NAME_TAX_DATE)
private LocalDate taxDate;
public static final String SERIALIZED_NAME_TAX_MODE = "taxMode";
@SerializedName(SERIALIZED_NAME_TAX_MODE)
private TaxMode taxMode;
public static final String SERIALIZED_NAME_TAX_RATE = "taxRate";
@SerializedName(SERIALIZED_NAME_TAX_RATE)
private BigDecimal taxRate;
public static final String SERIALIZED_NAME_TAX_RATE_DESCRIPTION = "taxRateDescription";
@SerializedName(SERIALIZED_NAME_TAX_RATE_DESCRIPTION)
private String taxRateDescription;
public static final String SERIALIZED_NAME_TAX_RATE_TYPE = "taxRateType";
@SerializedName(SERIALIZED_NAME_TAX_RATE_TYPE)
private TaxRateType taxRateType;
public CreateTaxationItemForInvoiceRequest() {
}
public CreateTaxationItemForInvoiceRequest exemptAmount(BigDecimal exemptAmount) {
this.exemptAmount = exemptAmount;
return this;
}
/**
* The calculated tax amount excluded due to the exemption.
* @return exemptAmount
*/
@javax.annotation.Nullable
public BigDecimal getExemptAmount() {
return exemptAmount;
}
public void setExemptAmount(BigDecimal exemptAmount) {
this.exemptAmount = exemptAmount;
}
public CreateTaxationItemForInvoiceRequest financeInformation(TaxItemsFinanceInformation financeInformation) {
this.financeInformation = financeInformation;
return this;
}
/**
* Get financeInformation
* @return financeInformation
*/
@javax.annotation.Nullable
public TaxItemsFinanceInformation getFinanceInformation() {
return financeInformation;
}
public void setFinanceInformation(TaxItemsFinanceInformation financeInformation) {
this.financeInformation = financeInformation;
}
public CreateTaxationItemForInvoiceRequest invoiceItemId(String invoiceItemId) {
this.invoiceItemId = invoiceItemId;
return this;
}
/**
* The ID of the invoice associated with the taxation item.
* @return invoiceItemId
*/
@javax.annotation.Nonnull
public String getInvoiceItemId() {
return invoiceItemId;
}
public void setInvoiceItemId(String invoiceItemId) {
this.invoiceItemId = invoiceItemId;
}
public CreateTaxationItemForInvoiceRequest jurisdiction(String jurisdiction) {
this.jurisdiction = jurisdiction;
return this;
}
/**
* The jurisdiction that applies the tax or VAT. This value is typically a state, province, county, or city.
* @return jurisdiction
*/
@javax.annotation.Nonnull
public String getJurisdiction() {
return jurisdiction;
}
public void setJurisdiction(String jurisdiction) {
this.jurisdiction = jurisdiction;
}
public CreateTaxationItemForInvoiceRequest locationCode(String locationCode) {
this.locationCode = locationCode;
return this;
}
/**
* The identifier for the location based on the value of the `taxCode` field.
* @return locationCode
*/
@javax.annotation.Nullable
public String getLocationCode() {
return locationCode;
}
public void setLocationCode(String locationCode) {
this.locationCode = locationCode;
}
public CreateTaxationItemForInvoiceRequest name(String name) {
this.name = name;
return this;
}
/**
* The name of taxation.
* @return name
*/
@javax.annotation.Nonnull
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public CreateTaxationItemForInvoiceRequest taxAmount(BigDecimal taxAmount) {
this.taxAmount = taxAmount;
return this;
}
/**
* The amount of the taxation item in the invoice item.
* @return taxAmount
*/
@javax.annotation.Nonnull
public BigDecimal getTaxAmount() {
return taxAmount;
}
public void setTaxAmount(BigDecimal taxAmount) {
this.taxAmount = taxAmount;
}
public CreateTaxationItemForInvoiceRequest applicableTaxUnRounded(BigDecimal applicableTaxUnRounded) {
this.applicableTaxUnRounded = applicableTaxUnRounded;
return this;
}
/**
* The unrounded amount of the tax.
* @return applicableTaxUnRounded
*/
@javax.annotation.Nullable
public BigDecimal getApplicableTaxUnRounded() {
return applicableTaxUnRounded;
}
public void setApplicableTaxUnRounded(BigDecimal applicableTaxUnRounded) {
this.applicableTaxUnRounded = applicableTaxUnRounded;
}
public CreateTaxationItemForInvoiceRequest country(String country) {
this.country = country;
return this;
}
/**
* The field which contains country code.
* @return country
*/
@javax.annotation.Nullable
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public CreateTaxationItemForInvoiceRequest taxCode(String taxCode) {
this.taxCode = taxCode;
return this;
}
/**
* The tax code identifies which tax rules and tax rates to apply to a specific invoice item.
* @return taxCode
*/
@javax.annotation.Nullable
public String getTaxCode() {
return taxCode;
}
public void setTaxCode(String taxCode) {
this.taxCode = taxCode;
}
public CreateTaxationItemForInvoiceRequest taxCodeDescription(String taxCodeDescription) {
this.taxCodeDescription = taxCodeDescription;
return this;
}
/**
* The description of the tax code.
* @return taxCodeDescription
*/
@javax.annotation.Nullable
public String getTaxCodeDescription() {
return taxCodeDescription;
}
public void setTaxCodeDescription(String taxCodeDescription) {
this.taxCodeDescription = taxCodeDescription;
}
public CreateTaxationItemForInvoiceRequest taxDate(LocalDate taxDate) {
this.taxDate = taxDate;
return this;
}
/**
* The date that the tax is applied to the invoice item, in `yyyy-mm-dd` format.
* @return taxDate
*/
@javax.annotation.Nonnull
public LocalDate getTaxDate() {
return taxDate;
}
public void setTaxDate(LocalDate taxDate) {
this.taxDate = taxDate;
}
public CreateTaxationItemForInvoiceRequest taxMode(TaxMode taxMode) {
this.taxMode = taxMode;
return this;
}
/**
* Get taxMode
* @return taxMode
*/
@javax.annotation.Nullable
public TaxMode getTaxMode() {
return taxMode;
}
public void setTaxMode(TaxMode taxMode) {
this.taxMode = taxMode;
}
public CreateTaxationItemForInvoiceRequest taxRate(BigDecimal taxRate) {
this.taxRate = taxRate;
return this;
}
/**
* The tax rate applied to the invoice item.
* @return taxRate
*/
@javax.annotation.Nonnull
public BigDecimal getTaxRate() {
return taxRate;
}
public void setTaxRate(BigDecimal taxRate) {
this.taxRate = taxRate;
}
public CreateTaxationItemForInvoiceRequest taxRateDescription(String taxRateDescription) {
this.taxRateDescription = taxRateDescription;
return this;
}
/**
* The description of the tax rate.
* @return taxRateDescription
*/
@javax.annotation.Nullable
public String getTaxRateDescription() {
return taxRateDescription;
}
public void setTaxRateDescription(String taxRateDescription) {
this.taxRateDescription = taxRateDescription;
}
public CreateTaxationItemForInvoiceRequest taxRateType(TaxRateType taxRateType) {
this.taxRateType = taxRateType;
return this;
}
/**
* Get taxRateType
* @return taxRateType
*/
@javax.annotation.Nonnull
public TaxRateType getTaxRateType() {
return taxRateType;
}
public void setTaxRateType(TaxRateType taxRateType) {
this.taxRateType = taxRateType;
}
/**
* 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 CreateTaxationItemForInvoiceRequest instance itself
*/
public CreateTaxationItemForInvoiceRequest 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;
}
CreateTaxationItemForInvoiceRequest createTaxationItemForInvoiceRequest = (CreateTaxationItemForInvoiceRequest) o;
return Objects.equals(this.exemptAmount, createTaxationItemForInvoiceRequest.exemptAmount) &&
Objects.equals(this.financeInformation, createTaxationItemForInvoiceRequest.financeInformation) &&
Objects.equals(this.invoiceItemId, createTaxationItemForInvoiceRequest.invoiceItemId) &&
Objects.equals(this.jurisdiction, createTaxationItemForInvoiceRequest.jurisdiction) &&
Objects.equals(this.locationCode, createTaxationItemForInvoiceRequest.locationCode) &&
Objects.equals(this.name, createTaxationItemForInvoiceRequest.name) &&
Objects.equals(this.taxAmount, createTaxationItemForInvoiceRequest.taxAmount) &&
Objects.equals(this.applicableTaxUnRounded, createTaxationItemForInvoiceRequest.applicableTaxUnRounded) &&
Objects.equals(this.country, createTaxationItemForInvoiceRequest.country) &&
Objects.equals(this.taxCode, createTaxationItemForInvoiceRequest.taxCode) &&
Objects.equals(this.taxCodeDescription, createTaxationItemForInvoiceRequest.taxCodeDescription) &&
Objects.equals(this.taxDate, createTaxationItemForInvoiceRequest.taxDate) &&
Objects.equals(this.taxMode, createTaxationItemForInvoiceRequest.taxMode) &&
Objects.equals(this.taxRate, createTaxationItemForInvoiceRequest.taxRate) &&
Objects.equals(this.taxRateDescription, createTaxationItemForInvoiceRequest.taxRateDescription) &&
Objects.equals(this.taxRateType, createTaxationItemForInvoiceRequest.taxRateType)&&
Objects.equals(this.additionalProperties, createTaxationItemForInvoiceRequest.additionalProperties);
}
@Override
public int hashCode() {
return Objects.hash(exemptAmount, financeInformation, invoiceItemId, jurisdiction, locationCode, name, taxAmount, applicableTaxUnRounded, country, taxCode, taxCodeDescription, taxDate, taxMode, taxRate, taxRateDescription, taxRateType, additionalProperties);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class CreateTaxationItemForInvoiceRequest {\n");
sb.append(" exemptAmount: ").append(toIndentedString(exemptAmount)).append("\n");
sb.append(" financeInformation: ").append(toIndentedString(financeInformation)).append("\n");
sb.append(" invoiceItemId: ").append(toIndentedString(invoiceItemId)).append("\n");
sb.append(" jurisdiction: ").append(toIndentedString(jurisdiction)).append("\n");
sb.append(" locationCode: ").append(toIndentedString(locationCode)).append("\n");
sb.append(" name: ").append(toIndentedString(name)).append("\n");
sb.append(" taxAmount: ").append(toIndentedString(taxAmount)).append("\n");
sb.append(" applicableTaxUnRounded: ").append(toIndentedString(applicableTaxUnRounded)).append("\n");
sb.append(" country: ").append(toIndentedString(country)).append("\n");
sb.append(" taxCode: ").append(toIndentedString(taxCode)).append("\n");
sb.append(" taxCodeDescription: ").append(toIndentedString(taxCodeDescription)).append("\n");
sb.append(" taxDate: ").append(toIndentedString(taxDate)).append("\n");
sb.append(" taxMode: ").append(toIndentedString(taxMode)).append("\n");
sb.append(" taxRate: ").append(toIndentedString(taxRate)).append("\n");
sb.append(" taxRateDescription: ").append(toIndentedString(taxRateDescription)).append("\n");
sb.append(" taxRateType: ").append(toIndentedString(taxRateType)).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("exemptAmount");
openapiFields.add("financeInformation");
openapiFields.add("invoiceItemId");
openapiFields.add("jurisdiction");
openapiFields.add("locationCode");
openapiFields.add("name");
openapiFields.add("taxAmount");
openapiFields.add("applicableTaxUnRounded");
openapiFields.add("country");
openapiFields.add("taxCode");
openapiFields.add("taxCodeDescription");
openapiFields.add("taxDate");
openapiFields.add("taxMode");
openapiFields.add("taxRate");
openapiFields.add("taxRateDescription");
openapiFields.add("taxRateType");
// a set of required properties/fields (JSON key names)
openapiRequiredFields = new HashSet();
openapiRequiredFields.add("invoiceItemId");
openapiRequiredFields.add("jurisdiction");
openapiRequiredFields.add("name");
openapiRequiredFields.add("taxAmount");
openapiRequiredFields.add("taxDate");
openapiRequiredFields.add("taxRate");
openapiRequiredFields.add("taxRateType");
}
/**
* 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 CreateTaxationItemForInvoiceRequest
*/
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
if (jsonElement == null) {
if (!CreateTaxationItemForInvoiceRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in CreateTaxationItemForInvoiceRequest is not found in the empty JSON string", CreateTaxationItemForInvoiceRequest.openapiRequiredFields.toString()));
}
}
// check to make sure all required properties/fields are present in the JSON string
for (String requiredField : CreateTaxationItemForInvoiceRequest.openapiRequiredFields) {
if (jsonElement.getAsJsonObject().get(requiredField) == null) {
throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString()));
}
}
JsonObject jsonObj = jsonElement.getAsJsonObject();
// validate the optional field `financeInformation`
if (jsonObj.get("financeInformation") != null && !jsonObj.get("financeInformation").isJsonNull()) {
TaxItemsFinanceInformation.validateJsonElement(jsonObj.get("financeInformation"));
}
if (!jsonObj.get("invoiceItemId").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `invoiceItemId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("invoiceItemId").toString()));
}
if (!jsonObj.get("jurisdiction").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `jurisdiction` to be a primitive type in the JSON string but got `%s`", jsonObj.get("jurisdiction").toString()));
}
if ((jsonObj.get("locationCode") != null && !jsonObj.get("locationCode").isJsonNull()) && !jsonObj.get("locationCode").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `locationCode` to be a primitive type in the JSON string but got `%s`", jsonObj.get("locationCode").toString()));
}
if (!jsonObj.get("name").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").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("taxCode") != null && !jsonObj.get("taxCode").isJsonNull()) && !jsonObj.get("taxCode").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `taxCode` to be a primitive type in the JSON string but got `%s`", jsonObj.get("taxCode").toString()));
}
if ((jsonObj.get("taxCodeDescription") != null && !jsonObj.get("taxCodeDescription").isJsonNull()) && !jsonObj.get("taxCodeDescription").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `taxCodeDescription` to be a primitive type in the JSON string but got `%s`", jsonObj.get("taxCodeDescription").toString()));
}
if ((jsonObj.get("taxMode") != null && !jsonObj.get("taxMode").isJsonNull()) && !jsonObj.get("taxMode").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `taxMode` to be a primitive type in the JSON string but got `%s`", jsonObj.get("taxMode").toString()));
}
// validate the optional field `taxMode`
if (jsonObj.get("taxMode") != null && !jsonObj.get("taxMode").isJsonNull()) {
TaxMode.validateJsonElement(jsonObj.get("taxMode"));
}
if ((jsonObj.get("taxRateDescription") != null && !jsonObj.get("taxRateDescription").isJsonNull()) && !jsonObj.get("taxRateDescription").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `taxRateDescription` to be a primitive type in the JSON string but got `%s`", jsonObj.get("taxRateDescription").toString()));
}
if (!jsonObj.get("taxRateType").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `taxRateType` to be a primitive type in the JSON string but got `%s`", jsonObj.get("taxRateType").toString()));
}
// validate the required field `taxRateType`
TaxRateType.validateJsonElement(jsonObj.get("taxRateType"));
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@SuppressWarnings("unchecked")
@Override
public TypeAdapter create(Gson gson, TypeToken type) {
if (!CreateTaxationItemForInvoiceRequest.class.isAssignableFrom(type.getRawType())) {
return null; // this class only serializes 'CreateTaxationItemForInvoiceRequest' and its subtypes
}
final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
final TypeAdapter thisAdapter
= gson.getDelegateAdapter(this, TypeToken.get(CreateTaxationItemForInvoiceRequest.class));
return (TypeAdapter) new TypeAdapter() {
@Override
public void write(JsonWriter out, CreateTaxationItemForInvoiceRequest 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 CreateTaxationItemForInvoiceRequest read(JsonReader in) throws IOException {
JsonElement jsonElement = elementAdapter.read(in);
validateJsonElement(jsonElement);
JsonObject jsonObj = jsonElement.getAsJsonObject();
// store additional fields in the deserialized instance
CreateTaxationItemForInvoiceRequest 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 CreateTaxationItemForInvoiceRequest given an JSON string
*
* @param jsonString JSON string
* @return An instance of CreateTaxationItemForInvoiceRequest
* @throws IOException if the JSON string is invalid with respect to CreateTaxationItemForInvoiceRequest
*/
public static CreateTaxationItemForInvoiceRequest fromJson(String jsonString) throws IOException {
return JSON.getGson().fromJson(jsonString, CreateTaxationItemForInvoiceRequest.class);
}
/**
* Convert an instance of CreateTaxationItemForInvoiceRequest to an JSON string
*
* @return JSON string
*/
public String toJson() {
return JSON.getGson().toJson(this);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy