com.zuora.model.CreateInvoiceRequest 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.BillingDocumentStatus;
import com.zuora.model.CreateAccountContact;
import com.zuora.model.CreateInvoiceItem;
import com.zuora.model.CustomRates;
import com.zuora.model.TransferredToAccountingStatus;
import java.io.IOException;
import java.time.LocalDate;
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;
/**
* CreateInvoiceRequest
*/
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.6.0")
public class CreateInvoiceRequest {
public static final String SERIALIZED_NAME_INTEGRATION_ID_N_S = "IntegrationId__NS";
@SerializedName(SERIALIZED_NAME_INTEGRATION_ID_N_S)
private String integrationIdNS;
public static final String SERIALIZED_NAME_INTEGRATION_STATUS_N_S = "IntegrationStatus__NS";
@SerializedName(SERIALIZED_NAME_INTEGRATION_STATUS_N_S)
private String integrationStatusNS;
public static final String SERIALIZED_NAME_SYNC_DATE_N_S = "SyncDate__NS";
@SerializedName(SERIALIZED_NAME_SYNC_DATE_N_S)
private String syncDateNS;
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_AUTO_PAY = "autoPay";
@SerializedName(SERIALIZED_NAME_AUTO_PAY)
private Boolean autoPay = false;
public static final String SERIALIZED_NAME_COMMENTS = "comments";
@SerializedName(SERIALIZED_NAME_COMMENTS)
private String comments;
public static final String SERIALIZED_NAME_CUSTOM_RATES = "customRates";
@SerializedName(SERIALIZED_NAME_CUSTOM_RATES)
private List customRates;
public static final String SERIALIZED_NAME_DUE_DATE = "dueDate";
@SerializedName(SERIALIZED_NAME_DUE_DATE)
private LocalDate dueDate;
public static final String SERIALIZED_NAME_INVOICE_DATE = "invoiceDate";
@SerializedName(SERIALIZED_NAME_INVOICE_DATE)
private LocalDate invoiceDate;
public static final String SERIALIZED_NAME_INVOICE_ITEMS = "invoiceItems";
@SerializedName(SERIALIZED_NAME_INVOICE_ITEMS)
private List invoiceItems;
public static final String SERIALIZED_NAME_INVOICE_NUMBER = "invoiceNumber";
@SerializedName(SERIALIZED_NAME_INVOICE_NUMBER)
private String invoiceNumber;
public static final String SERIALIZED_NAME_STATUS = "status";
@SerializedName(SERIALIZED_NAME_STATUS)
private BillingDocumentStatus status;
public static final String SERIALIZED_NAME_BILL_TO_CONTACT_ID = "billToContactId";
@SerializedName(SERIALIZED_NAME_BILL_TO_CONTACT_ID)
private String billToContactId;
public static final String SERIALIZED_NAME_PAYMENT_TERM = "paymentTerm";
@SerializedName(SERIALIZED_NAME_PAYMENT_TERM)
private String paymentTerm;
public static final String SERIALIZED_NAME_SEQUENCE_SET = "sequenceSet";
@SerializedName(SERIALIZED_NAME_SEQUENCE_SET)
private String sequenceSet;
public static final String SERIALIZED_NAME_SOLD_TO_CONTACT_ID = "soldToContactId";
@SerializedName(SERIALIZED_NAME_SOLD_TO_CONTACT_ID)
private String soldToContactId;
public static final String SERIALIZED_NAME_BILL_TO_CONTACT = "billToContact";
@SerializedName(SERIALIZED_NAME_BILL_TO_CONTACT)
private CreateAccountContact billToContact;
public static final String SERIALIZED_NAME_SOLD_TO_CONTACT = "soldToContact";
@SerializedName(SERIALIZED_NAME_SOLD_TO_CONTACT)
private CreateAccountContact soldToContact;
public static final String SERIALIZED_NAME_SOLD_TO_SAME_AS_BILL_TO = "soldToSameAsBillTo";
@SerializedName(SERIALIZED_NAME_SOLD_TO_SAME_AS_BILL_TO)
private Boolean soldToSameAsBillTo;
public static final String SERIALIZED_NAME_TEMPLATE_ID = "templateId";
@SerializedName(SERIALIZED_NAME_TEMPLATE_ID)
private String templateId;
public static final String SERIALIZED_NAME_TRANSFERRED_TO_ACCOUNTING = "transferredToAccounting";
@SerializedName(SERIALIZED_NAME_TRANSFERRED_TO_ACCOUNTING)
private TransferredToAccountingStatus transferredToAccounting;
public static final String SERIALIZED_NAME_SHIP_TO_CONTACT_ID = "shipToContactId";
@SerializedName(SERIALIZED_NAME_SHIP_TO_CONTACT_ID)
private String shipToContactId;
public static final String SERIALIZED_NAME_SHIP_TO_CONTACT = "shipToContact";
@SerializedName(SERIALIZED_NAME_SHIP_TO_CONTACT)
private CreateAccountContact shipToContact;
public static final String SERIALIZED_NAME_SHIP_TO_SAME_AS_BILL_TO = "shipToSameAsBillTo";
@SerializedName(SERIALIZED_NAME_SHIP_TO_SAME_AS_BILL_TO)
private Boolean shipToSameAsBillTo;
public CreateInvoiceRequest() {
}
public CreateInvoiceRequest integrationIdNS(String integrationIdNS) {
this.integrationIdNS = integrationIdNS;
return this;
}
/**
* ID of the corresponding object in NetSuite. Only available if you have installed the [Zuora Connector for NetSuite](https://www.zuora.com/connect/app/?appId=265).
* @return integrationIdNS
*/
@javax.annotation.Nullable
public String getIntegrationIdNS() {
return integrationIdNS;
}
public void setIntegrationIdNS(String integrationIdNS) {
this.integrationIdNS = integrationIdNS;
}
public CreateInvoiceRequest integrationStatusNS(String integrationStatusNS) {
this.integrationStatusNS = integrationStatusNS;
return this;
}
/**
* Status of the invoice's synchronization with NetSuite. Only available if you have installed the [Zuora Connector for NetSuite](https://www.zuora.com/connect/app/?appId=265).
* @return integrationStatusNS
*/
@javax.annotation.Nullable
public String getIntegrationStatusNS() {
return integrationStatusNS;
}
public void setIntegrationStatusNS(String integrationStatusNS) {
this.integrationStatusNS = integrationStatusNS;
}
public CreateInvoiceRequest syncDateNS(String syncDateNS) {
this.syncDateNS = syncDateNS;
return this;
}
/**
* Date when the invoice was synchronized with NetSuite. Only available if you have installed the [Zuora Connector for NetSuite](https://www.zuora.com/connect/app/?appId=265).
* @return syncDateNS
*/
@javax.annotation.Nullable
public String getSyncDateNS() {
return syncDateNS;
}
public void setSyncDateNS(String syncDateNS) {
this.syncDateNS = syncDateNS;
}
public CreateInvoiceRequest accountId(String accountId) {
this.accountId = accountId;
return this;
}
/**
* The ID of the account associated with the invoice. You must specify either `accountNumber` or `accountId` for a customer account. If both of them are specified, they must refer to the same customer account.
* @return accountId
*/
@javax.annotation.Nullable
public String getAccountId() {
return accountId;
}
public void setAccountId(String accountId) {
this.accountId = accountId;
}
public CreateInvoiceRequest accountNumber(String accountNumber) {
this.accountNumber = accountNumber;
return this;
}
/**
* The Number of the account associated with the invoice. You must specify either `accountNumber` or `accountId` for a customer account. If both of them are specified, they must refer to the same customer account.
* @return accountNumber
*/
@javax.annotation.Nullable
public String getAccountNumber() {
return accountNumber;
}
public void setAccountNumber(String accountNumber) {
this.accountNumber = accountNumber;
}
public CreateInvoiceRequest autoPay(Boolean autoPay) {
this.autoPay = autoPay;
return this;
}
/**
* Whether invoices are automatically picked up for processing in the corresponding payment run.
* @return autoPay
*/
@javax.annotation.Nullable
public Boolean getAutoPay() {
return autoPay;
}
public void setAutoPay(Boolean autoPay) {
this.autoPay = autoPay;
}
public CreateInvoiceRequest comments(String comments) {
this.comments = comments;
return this;
}
/**
* Comments about the invoice.
* @return comments
*/
@javax.annotation.Nullable
public String getComments() {
return comments;
}
public void setComments(String comments) {
this.comments = comments;
}
public CreateInvoiceRequest customRates(List customRates) {
this.customRates = customRates;
return this;
}
public CreateInvoiceRequest addCustomRatesItem(CustomRates customRatesItem) {
if (this.customRates == null) {
this.customRates = new ArrayList<>();
}
this.customRates.add(customRatesItem);
return this;
}
/**
* It contains Home currency and Reporting currency custom rates currencies. The maximum number of items is 2 (you can pass the Home currency item or Reporting currency item or both). **Note**: The API custom rate feature is permission controlled.
* @return customRates
*/
@javax.annotation.Nullable
public List getCustomRates() {
return customRates;
}
public void setCustomRates(List customRates) {
this.customRates = customRates;
}
public CreateInvoiceRequest dueDate(LocalDate dueDate) {
this.dueDate = dueDate;
return this;
}
/**
* The date by which the payment for this invoice is due, in `yyyy-mm-dd` format.
* @return dueDate
*/
@javax.annotation.Nullable
public LocalDate getDueDate() {
return dueDate;
}
public void setDueDate(LocalDate dueDate) {
this.dueDate = dueDate;
}
public CreateInvoiceRequest invoiceDate(LocalDate invoiceDate) {
this.invoiceDate = invoiceDate;
return this;
}
/**
* The date that appears on the invoice being created, in `yyyy-mm-dd` format. The value cannot fall in a closed accounting period.
* @return invoiceDate
*/
@javax.annotation.Nonnull
public LocalDate getInvoiceDate() {
return invoiceDate;
}
public void setInvoiceDate(LocalDate invoiceDate) {
this.invoiceDate = invoiceDate;
}
public CreateInvoiceRequest invoiceItems(List invoiceItems) {
this.invoiceItems = invoiceItems;
return this;
}
public CreateInvoiceRequest addInvoiceItemsItem(CreateInvoiceItem invoiceItemsItem) {
if (this.invoiceItems == null) {
this.invoiceItems = new ArrayList<>();
}
this.invoiceItems.add(invoiceItemsItem);
return this;
}
/**
* Container for invoice items. The maximum number of invoice items is 1,000.
* @return invoiceItems
*/
@javax.annotation.Nonnull
public List getInvoiceItems() {
return invoiceItems;
}
public void setInvoiceItems(List invoiceItems) {
this.invoiceItems = invoiceItems;
}
public CreateInvoiceRequest invoiceNumber(String invoiceNumber) {
this.invoiceNumber = invoiceNumber;
return this;
}
/**
* A customized invoice number with the following format requirements: - Max length: 32 characters - Acceptable characters: a-z,A-Z,0-9,-,_, The value must be unique in the system, otherwise it may cause issues with bill runs and subscribe/amend. Check out [things to note and troubleshooting steps](https://knowledgecenter.zuora.com/Billing/Billing_and_Payments/IA_Invoices/Unified_Invoicing/Import_external_invoices_as_standalone_invoices?#Customizing_invoice_number).
* @return invoiceNumber
*/
@javax.annotation.Nullable
public String getInvoiceNumber() {
return invoiceNumber;
}
public void setInvoiceNumber(String invoiceNumber) {
this.invoiceNumber = invoiceNumber;
}
public CreateInvoiceRequest status(BillingDocumentStatus status) {
this.status = status;
return this;
}
/**
* Get status
* @return status
*/
@javax.annotation.Nullable
public BillingDocumentStatus getStatus() {
return status;
}
public void setStatus(BillingDocumentStatus status) {
this.status = status;
}
public CreateInvoiceRequest billToContactId(String billToContactId) {
this.billToContactId = billToContactId;
return this;
}
/**
* The ID of the bill-to contact associated with the invoice.
* @return billToContactId
*/
@javax.annotation.Nullable
public String getBillToContactId() {
return billToContactId;
}
public void setBillToContactId(String billToContactId) {
this.billToContactId = billToContactId;
}
public CreateInvoiceRequest paymentTerm(String paymentTerm) {
this.paymentTerm = paymentTerm;
return this;
}
/**
* The name of payment term associated with the invoice.
* @return paymentTerm
*/
@javax.annotation.Nullable
public String getPaymentTerm() {
return paymentTerm;
}
public void setPaymentTerm(String paymentTerm) {
this.paymentTerm = paymentTerm;
}
public CreateInvoiceRequest sequenceSet(String sequenceSet) {
this.sequenceSet = sequenceSet;
return this;
}
/**
* The ID or name of the sequence set associated with the invoice.
* @return sequenceSet
*/
@javax.annotation.Nullable
public String getSequenceSet() {
return sequenceSet;
}
public void setSequenceSet(String sequenceSet) {
this.sequenceSet = sequenceSet;
}
public CreateInvoiceRequest soldToContactId(String soldToContactId) {
this.soldToContactId = soldToContactId;
return this;
}
/**
* The ID of the sold-to contact associated with the invoice.
* @return soldToContactId
*/
@javax.annotation.Nullable
public String getSoldToContactId() {
return soldToContactId;
}
public void setSoldToContactId(String soldToContactId) {
this.soldToContactId = soldToContactId;
}
public CreateInvoiceRequest billToContact(CreateAccountContact billToContact) {
this.billToContact = billToContact;
return this;
}
/**
* Get billToContact
* @return billToContact
*/
@javax.annotation.Nullable
public CreateAccountContact getBillToContact() {
return billToContact;
}
public void setBillToContact(CreateAccountContact billToContact) {
this.billToContact = billToContact;
}
public CreateInvoiceRequest soldToContact(CreateAccountContact soldToContact) {
this.soldToContact = soldToContact;
return this;
}
/**
* Get soldToContact
* @return soldToContact
*/
@javax.annotation.Nullable
public CreateAccountContact getSoldToContact() {
return soldToContact;
}
public void setSoldToContact(CreateAccountContact soldToContact) {
this.soldToContact = soldToContact;
}
public CreateInvoiceRequest soldToSameAsBillTo(Boolean soldToSameAsBillTo) {
this.soldToSameAsBillTo = soldToSameAsBillTo;
return this;
}
/**
* Whether the sold-to contact and bill-to contact are the same entity. The created invoice has the same bill-to contact and sold-to contact entity only when all the following conditions are met in the request body: - This field is set to `true`. - A bill-to contact is specified. - No sold-to contact is specified.
* @return soldToSameAsBillTo
*/
@javax.annotation.Nullable
public Boolean getSoldToSameAsBillTo() {
return soldToSameAsBillTo;
}
public void setSoldToSameAsBillTo(Boolean soldToSameAsBillTo) {
this.soldToSameAsBillTo = soldToSameAsBillTo;
}
public CreateInvoiceRequest templateId(String templateId) {
this.templateId = templateId;
return this;
}
/**
* The ID of the invoice template. **Note**: This field requires Flexible Billing Attribute.
* @return templateId
*/
@javax.annotation.Nullable
public String getTemplateId() {
return templateId;
}
public void setTemplateId(String templateId) {
this.templateId = templateId;
}
public CreateInvoiceRequest transferredToAccounting(TransferredToAccountingStatus transferredToAccounting) {
this.transferredToAccounting = transferredToAccounting;
return this;
}
/**
* Get transferredToAccounting
* @return transferredToAccounting
*/
@javax.annotation.Nullable
public TransferredToAccountingStatus getTransferredToAccounting() {
return transferredToAccounting;
}
public void setTransferredToAccounting(TransferredToAccountingStatus transferredToAccounting) {
this.transferredToAccounting = transferredToAccounting;
}
public CreateInvoiceRequest shipToContactId(String shipToContactId) {
this.shipToContactId = shipToContactId;
return this;
}
/**
* The ID of the ship-to contact associated with the invoice.
* @return shipToContactId
*/
@javax.annotation.Nullable
public String getShipToContactId() {
return shipToContactId;
}
public void setShipToContactId(String shipToContactId) {
this.shipToContactId = shipToContactId;
}
public CreateInvoiceRequest shipToContact(CreateAccountContact shipToContact) {
this.shipToContact = shipToContact;
return this;
}
/**
* Get shipToContact
* @return shipToContact
*/
@javax.annotation.Nullable
public CreateAccountContact getShipToContact() {
return shipToContact;
}
public void setShipToContact(CreateAccountContact shipToContact) {
this.shipToContact = shipToContact;
}
public CreateInvoiceRequest shipToSameAsBillTo(Boolean shipToSameAsBillTo) {
this.shipToSameAsBillTo = shipToSameAsBillTo;
return this;
}
/**
* Whether the ship-to contact and bill-to contact are the same entity. The created invoice has the same bill-to contact and ship-to contact entity only when all the following conditions are met in the request body: - This field is set to `true`. - A bill-to contact is specified. - No ship-to contact is specified.
* @return shipToSameAsBillTo
*/
@javax.annotation.Nullable
public Boolean getShipToSameAsBillTo() {
return shipToSameAsBillTo;
}
public void setShipToSameAsBillTo(Boolean shipToSameAsBillTo) {
this.shipToSameAsBillTo = shipToSameAsBillTo;
}
/**
* 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 CreateInvoiceRequest instance itself
*/
public CreateInvoiceRequest 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;
}
CreateInvoiceRequest createInvoiceRequest = (CreateInvoiceRequest) o;
return Objects.equals(this.integrationIdNS, createInvoiceRequest.integrationIdNS) &&
Objects.equals(this.integrationStatusNS, createInvoiceRequest.integrationStatusNS) &&
Objects.equals(this.syncDateNS, createInvoiceRequest.syncDateNS) &&
Objects.equals(this.accountId, createInvoiceRequest.accountId) &&
Objects.equals(this.accountNumber, createInvoiceRequest.accountNumber) &&
Objects.equals(this.autoPay, createInvoiceRequest.autoPay) &&
Objects.equals(this.comments, createInvoiceRequest.comments) &&
Objects.equals(this.customRates, createInvoiceRequest.customRates) &&
Objects.equals(this.dueDate, createInvoiceRequest.dueDate) &&
Objects.equals(this.invoiceDate, createInvoiceRequest.invoiceDate) &&
Objects.equals(this.invoiceItems, createInvoiceRequest.invoiceItems) &&
Objects.equals(this.invoiceNumber, createInvoiceRequest.invoiceNumber) &&
Objects.equals(this.status, createInvoiceRequest.status) &&
Objects.equals(this.billToContactId, createInvoiceRequest.billToContactId) &&
Objects.equals(this.paymentTerm, createInvoiceRequest.paymentTerm) &&
Objects.equals(this.sequenceSet, createInvoiceRequest.sequenceSet) &&
Objects.equals(this.soldToContactId, createInvoiceRequest.soldToContactId) &&
Objects.equals(this.billToContact, createInvoiceRequest.billToContact) &&
Objects.equals(this.soldToContact, createInvoiceRequest.soldToContact) &&
Objects.equals(this.soldToSameAsBillTo, createInvoiceRequest.soldToSameAsBillTo) &&
Objects.equals(this.templateId, createInvoiceRequest.templateId) &&
Objects.equals(this.transferredToAccounting, createInvoiceRequest.transferredToAccounting) &&
Objects.equals(this.shipToContactId, createInvoiceRequest.shipToContactId) &&
Objects.equals(this.shipToContact, createInvoiceRequest.shipToContact) &&
Objects.equals(this.shipToSameAsBillTo, createInvoiceRequest.shipToSameAsBillTo)&&
Objects.equals(this.additionalProperties, createInvoiceRequest.additionalProperties);
}
@Override
public int hashCode() {
return Objects.hash(integrationIdNS, integrationStatusNS, syncDateNS, accountId, accountNumber, autoPay, comments, customRates, dueDate, invoiceDate, invoiceItems, invoiceNumber, status, billToContactId, paymentTerm, sequenceSet, soldToContactId, billToContact, soldToContact, soldToSameAsBillTo, templateId, transferredToAccounting, shipToContactId, shipToContact, shipToSameAsBillTo, additionalProperties);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class CreateInvoiceRequest {\n");
sb.append(" integrationIdNS: ").append(toIndentedString(integrationIdNS)).append("\n");
sb.append(" integrationStatusNS: ").append(toIndentedString(integrationStatusNS)).append("\n");
sb.append(" syncDateNS: ").append(toIndentedString(syncDateNS)).append("\n");
sb.append(" accountId: ").append(toIndentedString(accountId)).append("\n");
sb.append(" accountNumber: ").append(toIndentedString(accountNumber)).append("\n");
sb.append(" autoPay: ").append(toIndentedString(autoPay)).append("\n");
sb.append(" comments: ").append(toIndentedString(comments)).append("\n");
sb.append(" customRates: ").append(toIndentedString(customRates)).append("\n");
sb.append(" dueDate: ").append(toIndentedString(dueDate)).append("\n");
sb.append(" invoiceDate: ").append(toIndentedString(invoiceDate)).append("\n");
sb.append(" invoiceItems: ").append(toIndentedString(invoiceItems)).append("\n");
sb.append(" invoiceNumber: ").append(toIndentedString(invoiceNumber)).append("\n");
sb.append(" status: ").append(toIndentedString(status)).append("\n");
sb.append(" billToContactId: ").append(toIndentedString(billToContactId)).append("\n");
sb.append(" paymentTerm: ").append(toIndentedString(paymentTerm)).append("\n");
sb.append(" sequenceSet: ").append(toIndentedString(sequenceSet)).append("\n");
sb.append(" soldToContactId: ").append(toIndentedString(soldToContactId)).append("\n");
sb.append(" billToContact: ").append(toIndentedString(billToContact)).append("\n");
sb.append(" soldToContact: ").append(toIndentedString(soldToContact)).append("\n");
sb.append(" soldToSameAsBillTo: ").append(toIndentedString(soldToSameAsBillTo)).append("\n");
sb.append(" templateId: ").append(toIndentedString(templateId)).append("\n");
sb.append(" transferredToAccounting: ").append(toIndentedString(transferredToAccounting)).append("\n");
sb.append(" shipToContactId: ").append(toIndentedString(shipToContactId)).append("\n");
sb.append(" shipToContact: ").append(toIndentedString(shipToContact)).append("\n");
sb.append(" shipToSameAsBillTo: ").append(toIndentedString(shipToSameAsBillTo)).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("IntegrationId__NS");
openapiFields.add("IntegrationStatus__NS");
openapiFields.add("SyncDate__NS");
openapiFields.add("accountId");
openapiFields.add("accountNumber");
openapiFields.add("autoPay");
openapiFields.add("comments");
openapiFields.add("customRates");
openapiFields.add("dueDate");
openapiFields.add("invoiceDate");
openapiFields.add("invoiceItems");
openapiFields.add("invoiceNumber");
openapiFields.add("status");
openapiFields.add("billToContactId");
openapiFields.add("paymentTerm");
openapiFields.add("sequenceSet");
openapiFields.add("soldToContactId");
openapiFields.add("billToContact");
openapiFields.add("soldToContact");
openapiFields.add("soldToSameAsBillTo");
openapiFields.add("templateId");
openapiFields.add("transferredToAccounting");
openapiFields.add("shipToContactId");
openapiFields.add("shipToContact");
openapiFields.add("shipToSameAsBillTo");
// a set of required properties/fields (JSON key names)
openapiRequiredFields = new HashSet();
openapiRequiredFields.add("invoiceDate");
openapiRequiredFields.add("invoiceItems");
}
/**
* 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 CreateInvoiceRequest
*/
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
if (jsonElement == null) {
if (!CreateInvoiceRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in CreateInvoiceRequest is not found in the empty JSON string", CreateInvoiceRequest.openapiRequiredFields.toString()));
}
}
// check to make sure all required properties/fields are present in the JSON string
for (String requiredField : CreateInvoiceRequest.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();
if ((jsonObj.get("IntegrationId__NS") != null && !jsonObj.get("IntegrationId__NS").isJsonNull()) && !jsonObj.get("IntegrationId__NS").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `IntegrationId__NS` to be a primitive type in the JSON string but got `%s`", jsonObj.get("IntegrationId__NS").toString()));
}
if ((jsonObj.get("IntegrationStatus__NS") != null && !jsonObj.get("IntegrationStatus__NS").isJsonNull()) && !jsonObj.get("IntegrationStatus__NS").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `IntegrationStatus__NS` to be a primitive type in the JSON string but got `%s`", jsonObj.get("IntegrationStatus__NS").toString()));
}
if ((jsonObj.get("SyncDate__NS") != null && !jsonObj.get("SyncDate__NS").isJsonNull()) && !jsonObj.get("SyncDate__NS").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `SyncDate__NS` to be a primitive type in the JSON string but got `%s`", jsonObj.get("SyncDate__NS").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("comments") != null && !jsonObj.get("comments").isJsonNull()) && !jsonObj.get("comments").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `comments` to be a primitive type in the JSON string but got `%s`", jsonObj.get("comments").toString()));
}
if (jsonObj.get("customRates") != null && !jsonObj.get("customRates").isJsonNull()) {
JsonArray jsonArraycustomRates = jsonObj.getAsJsonArray("customRates");
if (jsonArraycustomRates != null) {
// ensure the json data is an array
if (!jsonObj.get("customRates").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `customRates` to be an array in the JSON string but got `%s`", jsonObj.get("customRates").toString()));
}
// validate the optional field `customRates` (array)
for (int i = 0; i < jsonArraycustomRates.size(); i++) {
CustomRates.validateJsonElement(jsonArraycustomRates.get(i));
};
}
}
// ensure the json data is an array
if (!jsonObj.get("invoiceItems").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `invoiceItems` to be an array in the JSON string but got `%s`", jsonObj.get("invoiceItems").toString()));
}
JsonArray jsonArrayinvoiceItems = jsonObj.getAsJsonArray("invoiceItems");
// validate the required field `invoiceItems` (array)
for (int i = 0; i < jsonArrayinvoiceItems.size(); i++) {
CreateInvoiceItem.validateJsonElement(jsonArrayinvoiceItems.get(i));
};
if ((jsonObj.get("invoiceNumber") != null && !jsonObj.get("invoiceNumber").isJsonNull()) && !jsonObj.get("invoiceNumber").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `invoiceNumber` to be a primitive type in the JSON string but got `%s`", jsonObj.get("invoiceNumber").toString()));
}
if ((jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) && !jsonObj.get("status").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString()));
}
// validate the optional field `status`
if (jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) {
BillingDocumentStatus.validateJsonElement(jsonObj.get("status"));
}
if ((jsonObj.get("billToContactId") != null && !jsonObj.get("billToContactId").isJsonNull()) && !jsonObj.get("billToContactId").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `billToContactId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("billToContactId").toString()));
}
if ((jsonObj.get("paymentTerm") != null && !jsonObj.get("paymentTerm").isJsonNull()) && !jsonObj.get("paymentTerm").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `paymentTerm` to be a primitive type in the JSON string but got `%s`", jsonObj.get("paymentTerm").toString()));
}
if ((jsonObj.get("sequenceSet") != null && !jsonObj.get("sequenceSet").isJsonNull()) && !jsonObj.get("sequenceSet").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `sequenceSet` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sequenceSet").toString()));
}
if ((jsonObj.get("soldToContactId") != null && !jsonObj.get("soldToContactId").isJsonNull()) && !jsonObj.get("soldToContactId").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `soldToContactId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("soldToContactId").toString()));
}
// validate the optional field `billToContact`
if (jsonObj.get("billToContact") != null && !jsonObj.get("billToContact").isJsonNull()) {
CreateAccountContact.validateJsonElement(jsonObj.get("billToContact"));
}
// validate the optional field `soldToContact`
if (jsonObj.get("soldToContact") != null && !jsonObj.get("soldToContact").isJsonNull()) {
CreateAccountContact.validateJsonElement(jsonObj.get("soldToContact"));
}
if ((jsonObj.get("templateId") != null && !jsonObj.get("templateId").isJsonNull()) && !jsonObj.get("templateId").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `templateId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("templateId").toString()));
}
if ((jsonObj.get("transferredToAccounting") != null && !jsonObj.get("transferredToAccounting").isJsonNull()) && !jsonObj.get("transferredToAccounting").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `transferredToAccounting` to be a primitive type in the JSON string but got `%s`", jsonObj.get("transferredToAccounting").toString()));
}
// validate the optional field `transferredToAccounting`
if (jsonObj.get("transferredToAccounting") != null && !jsonObj.get("transferredToAccounting").isJsonNull()) {
TransferredToAccountingStatus.validateJsonElement(jsonObj.get("transferredToAccounting"));
}
if ((jsonObj.get("shipToContactId") != null && !jsonObj.get("shipToContactId").isJsonNull()) && !jsonObj.get("shipToContactId").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `shipToContactId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("shipToContactId").toString()));
}
// validate the optional field `shipToContact`
if (jsonObj.get("shipToContact") != null && !jsonObj.get("shipToContact").isJsonNull()) {
CreateAccountContact.validateJsonElement(jsonObj.get("shipToContact"));
}
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@SuppressWarnings("unchecked")
@Override
public TypeAdapter create(Gson gson, TypeToken type) {
if (!CreateInvoiceRequest.class.isAssignableFrom(type.getRawType())) {
return null; // this class only serializes 'CreateInvoiceRequest' and its subtypes
}
final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
final TypeAdapter thisAdapter
= gson.getDelegateAdapter(this, TypeToken.get(CreateInvoiceRequest.class));
return (TypeAdapter) new TypeAdapter() {
@Override
public void write(JsonWriter out, CreateInvoiceRequest 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 CreateInvoiceRequest read(JsonReader in) throws IOException {
JsonElement jsonElement = elementAdapter.read(in);
validateJsonElement(jsonElement);
JsonObject jsonObj = jsonElement.getAsJsonObject();
// store additional fields in the deserialized instance
CreateInvoiceRequest 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 CreateInvoiceRequest given an JSON string
*
* @param jsonString JSON string
* @return An instance of CreateInvoiceRequest
* @throws IOException if the JSON string is invalid with respect to CreateInvoiceRequest
*/
public static CreateInvoiceRequest fromJson(String jsonString) throws IOException {
return JSON.getGson().fromJson(jsonString, CreateInvoiceRequest.class);
}
/**
* Convert an instance of CreateInvoiceRequest to an JSON string
*
* @return JSON string
*/
public String toJson() {
return JSON.getGson().toJson(this);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy