com.zuora.model.CreateBillRunRequest 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.BillRunFilter;
import com.zuora.model.BillRunSchedule;
import com.zuora.model.BillRunType;
import com.zuora.model.ChargeType;
import com.zuora.model.OrganizationLabel;
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;
/**
* CreateBillRunRequest
*/
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.6.0")
public class CreateBillRunRequest {
public static final String SERIALIZED_NAME_NAME = "name";
@SerializedName(SERIALIZED_NAME_NAME)
private String name;
public static final String SERIALIZED_NAME_BATCHES = "batches";
@SerializedName(SERIALIZED_NAME_BATCHES)
private List batches;
public static final String SERIALIZED_NAME_BILL_CYCLE_DAY = "billCycleDay";
@SerializedName(SERIALIZED_NAME_BILL_CYCLE_DAY)
private String billCycleDay;
public static final String SERIALIZED_NAME_BILL_RUN_FILTERS = "billRunFilters";
@SerializedName(SERIALIZED_NAME_BILL_RUN_FILTERS)
private List billRunFilters;
public static final String SERIALIZED_NAME_BILL_RUN_TYPE = "billRunType";
@SerializedName(SERIALIZED_NAME_BILL_RUN_TYPE)
private BillRunType billRunType;
public static final String SERIALIZED_NAME_CHARGE_TYPE_TO_EXCLUDE = "chargeTypeToExclude";
@SerializedName(SERIALIZED_NAME_CHARGE_TYPE_TO_EXCLUDE)
private List chargeTypeToExclude;
public static final String SERIALIZED_NAME_AUTO_EMAIL = "autoEmail";
@SerializedName(SERIALIZED_NAME_AUTO_EMAIL)
private Boolean autoEmail = false;
public static final String SERIALIZED_NAME_AUTO_POST = "autoPost";
@SerializedName(SERIALIZED_NAME_AUTO_POST)
private Boolean autoPost = false;
public static final String SERIALIZED_NAME_AUTO_RENEWAL = "autoRenewal";
@SerializedName(SERIALIZED_NAME_AUTO_RENEWAL)
private Boolean autoRenewal = false;
public static final String SERIALIZED_NAME_NO_EMAIL_FOR_ZERO_AMOUNT_INVOICE = "noEmailForZeroAmountInvoice";
@SerializedName(SERIALIZED_NAME_NO_EMAIL_FOR_ZERO_AMOUNT_INVOICE)
private Boolean noEmailForZeroAmountInvoice = false;
public static final String SERIALIZED_NAME_SCHEDULE = "schedule";
@SerializedName(SERIALIZED_NAME_SCHEDULE)
private BillRunSchedule schedule;
public static final String SERIALIZED_NAME_INVOICE_DATE = "invoiceDate";
@SerializedName(SERIALIZED_NAME_INVOICE_DATE)
private LocalDate invoiceDate;
public static final String SERIALIZED_NAME_INVOICE_DATE_MONTH_OFFSET = "invoiceDateMonthOffset";
@SerializedName(SERIALIZED_NAME_INVOICE_DATE_MONTH_OFFSET)
private Integer invoiceDateMonthOffset;
public static final String SERIALIZED_NAME_INVOICE_DATE_DAY_OF_MONTH = "invoiceDateDayOfMonth";
@SerializedName(SERIALIZED_NAME_INVOICE_DATE_DAY_OF_MONTH)
private Integer invoiceDateDayOfMonth;
public static final String SERIALIZED_NAME_TARGET_DATE = "targetDate";
@SerializedName(SERIALIZED_NAME_TARGET_DATE)
private LocalDate targetDate;
public static final String SERIALIZED_NAME_TARGET_DATE_MONTH_OFFSET = "targetDateMonthOffset";
@SerializedName(SERIALIZED_NAME_TARGET_DATE_MONTH_OFFSET)
private Integer targetDateMonthOffset;
public static final String SERIALIZED_NAME_TARGET_DATE_DAY_OF_MONTH = "targetDateDayOfMonth";
@SerializedName(SERIALIZED_NAME_TARGET_DATE_DAY_OF_MONTH)
private Integer targetDateDayOfMonth;
public static final String SERIALIZED_NAME_ORGANIZATION_LABELS = "organizationLabels";
@SerializedName(SERIALIZED_NAME_ORGANIZATION_LABELS)
private List organizationLabels;
public CreateBillRunRequest() {
}
public CreateBillRunRequest name(String name) {
this.name = name;
return this;
}
/**
* The name of the bill run.
* @return name
*/
@javax.annotation.Nullable
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public CreateBillRunRequest batches(List batches) {
this.batches = batches;
return this;
}
public CreateBillRunRequest addBatchesItem(String batchesItem) {
if (this.batches == null) {
this.batches = new ArrayList<>();
}
this.batches.add(batchesItem);
return this;
}
/**
* The batch of accounts for this bill run. You can only specify either this field or the `billRunFilters` field. **Values:** `AllBatches` or an array of `Batch*n*` where *n* is one of numbers 1 - 50, for example, `Batch7`.
* @return batches
*/
@javax.annotation.Nullable
public List getBatches() {
return batches;
}
public void setBatches(List batches) {
this.batches = batches;
}
public CreateBillRunRequest billCycleDay(String billCycleDay) {
this.billCycleDay = billCycleDay;
return this;
}
/**
* The day of the bill cycle. This field is only valid if the `batches` field is specified. **Values:** - `AllBillCycleDays` or one of numbers 1 - 31 for an ad-hoc bill run - `AllBillCycleDays`, one of numbers 1 - 31, or `AsRunDay` for a scheduled bill run
* @return billCycleDay
*/
@javax.annotation.Nullable
public String getBillCycleDay() {
return billCycleDay;
}
public void setBillCycleDay(String billCycleDay) {
this.billCycleDay = billCycleDay;
}
public CreateBillRunRequest billRunFilters(List billRunFilters) {
this.billRunFilters = billRunFilters;
return this;
}
public CreateBillRunRequest addBillRunFiltersItem(BillRunFilter billRunFiltersItem) {
if (this.billRunFilters == null) {
this.billRunFilters = new ArrayList<>();
}
this.billRunFilters.add(billRunFiltersItem);
return this;
}
/**
* The target account or subscriptions for this bill run. You can only specify either this field or the `batches` field.
* @return billRunFilters
*/
@javax.annotation.Nullable
public List getBillRunFilters() {
return billRunFilters;
}
public void setBillRunFilters(List billRunFilters) {
this.billRunFilters = billRunFilters;
}
public CreateBillRunRequest billRunType(BillRunType billRunType) {
this.billRunType = billRunType;
return this;
}
/**
* Get billRunType
* @return billRunType
*/
@javax.annotation.Nullable
public BillRunType getBillRunType() {
return billRunType;
}
public void setBillRunType(BillRunType billRunType) {
this.billRunType = billRunType;
}
public CreateBillRunRequest chargeTypeToExclude(List chargeTypeToExclude) {
this.chargeTypeToExclude = chargeTypeToExclude;
return this;
}
public CreateBillRunRequest addChargeTypeToExcludeItem(ChargeType chargeTypeToExcludeItem) {
if (this.chargeTypeToExclude == null) {
this.chargeTypeToExclude = new ArrayList<>();
}
this.chargeTypeToExclude.add(chargeTypeToExcludeItem);
return this;
}
/**
* The types of the charges to be excluded from the generation of billing documents. You can specify at most two charge types in the array.
* @return chargeTypeToExclude
*/
@javax.annotation.Nullable
public List getChargeTypeToExclude() {
return chargeTypeToExclude;
}
public void setChargeTypeToExclude(List chargeTypeToExclude) {
this.chargeTypeToExclude = chargeTypeToExclude;
}
public CreateBillRunRequest autoEmail(Boolean autoEmail) {
this.autoEmail = autoEmail;
return this;
}
/**
* Whether to automatically send emails after Auto-Post is complete. **Note:** To use this field, you must first set the <a href=\"https://knowledgecenter.zuora.com/CB_Billing/Billing_Settings/Define_Billing_Rules\" target=\"_blank\">Support Bill Run Auto-Post?</a> billing rule to **Yes** through the Zuora UI.
* @return autoEmail
*/
@javax.annotation.Nullable
public Boolean getAutoEmail() {
return autoEmail;
}
public void setAutoEmail(Boolean autoEmail) {
this.autoEmail = autoEmail;
}
public CreateBillRunRequest autoPost(Boolean autoPost) {
this.autoPost = autoPost;
return this;
}
/**
* Whether to automatically post the bill run after the bill run is created. **Note:** To use this field, you must first set the <a href=\"https://knowledgecenter.zuora.com/CB_Billing/Billing_Settings/Define_Billing_Rules\" target=\"_blank\">Support Bill Run Auto-Post?</a> billing rule to **Yes** through the Zuora UI.
* @return autoPost
*/
@javax.annotation.Nullable
public Boolean getAutoPost() {
return autoPost;
}
public void setAutoPost(Boolean autoPost) {
this.autoPost = autoPost;
}
public CreateBillRunRequest autoRenewal(Boolean autoRenewal) {
this.autoRenewal = autoRenewal;
return this;
}
/**
* Whether to automatically renew auto-renew subscriptions that are up for renewal.
* @return autoRenewal
*/
@javax.annotation.Nullable
public Boolean getAutoRenewal() {
return autoRenewal;
}
public void setAutoRenewal(Boolean autoRenewal) {
this.autoRenewal = autoRenewal;
}
public CreateBillRunRequest noEmailForZeroAmountInvoice(Boolean noEmailForZeroAmountInvoice) {
this.noEmailForZeroAmountInvoice = noEmailForZeroAmountInvoice;
return this;
}
/**
* Whether to suppress emails for invoices with zero total amount generated in this bill run after the bill run is complete. It is best practice to not send emails for invoices with zero amount.
* @return noEmailForZeroAmountInvoice
*/
@javax.annotation.Nullable
public Boolean getNoEmailForZeroAmountInvoice() {
return noEmailForZeroAmountInvoice;
}
public void setNoEmailForZeroAmountInvoice(Boolean noEmailForZeroAmountInvoice) {
this.noEmailForZeroAmountInvoice = noEmailForZeroAmountInvoice;
}
public CreateBillRunRequest schedule(BillRunSchedule schedule) {
this.schedule = schedule;
return this;
}
/**
* Get schedule
* @return schedule
*/
@javax.annotation.Nullable
public BillRunSchedule getSchedule() {
return schedule;
}
public void setSchedule(BillRunSchedule schedule) {
this.schedule = schedule;
}
public CreateBillRunRequest invoiceDate(LocalDate invoiceDate) {
this.invoiceDate = invoiceDate;
return this;
}
/**
* The invoice date for the bill run. - When creating an ad-hoc bill run, if you do not specify any value for this field, the default value is the current date. - When creating a scheduled bill run, if you do not specify any value for this field, the invoice date is the value of the `repeatFrom` field.
* @return invoiceDate
*/
@javax.annotation.Nullable
public LocalDate getInvoiceDate() {
return invoiceDate;
}
public void setInvoiceDate(LocalDate invoiceDate) {
this.invoiceDate = invoiceDate;
}
public CreateBillRunRequest invoiceDateMonthOffset(Integer invoiceDateMonthOffset) {
this.invoiceDateMonthOffset = invoiceDateMonthOffset;
return this;
}
/**
* The month offset of invoice date for this bill run based on run date, only valid for monthly scheduled bill runs. invoiceDateOffset and invoiceDateMonthOffset/invoiceDateDayOfMonth are mutually exclusive. invoiceDateMonthOffset and invoiceDateDayOfMonth coexist.
* @return invoiceDateMonthOffset
*/
@javax.annotation.Nullable
public Integer getInvoiceDateMonthOffset() {
return invoiceDateMonthOffset;
}
public void setInvoiceDateMonthOffset(Integer invoiceDateMonthOffset) {
this.invoiceDateMonthOffset = invoiceDateMonthOffset;
}
public CreateBillRunRequest invoiceDateDayOfMonth(Integer invoiceDateDayOfMonth) {
this.invoiceDateDayOfMonth = invoiceDateDayOfMonth;
return this;
}
/**
* The day of month of invoice date for this bill run, only valid for monthly scheduled bill runs. Specify any day of the month (1-31, where 31 = end-of-month). invoiceDateOffset and invoiceDateMonthOffset/invoiceDateDayOfMonth are mutually exclusive. invoiceDateMonthOffset and invoiceDateDayOfMonth coexist.
* minimum: 1
* maximum: 31
* @return invoiceDateDayOfMonth
*/
@javax.annotation.Nullable
public Integer getInvoiceDateDayOfMonth() {
return invoiceDateDayOfMonth;
}
public void setInvoiceDateDayOfMonth(Integer invoiceDateDayOfMonth) {
this.invoiceDateDayOfMonth = invoiceDateDayOfMonth;
}
public CreateBillRunRequest targetDate(LocalDate targetDate) {
this.targetDate = targetDate;
return this;
}
/**
* The target date for this bill run. - You must specify this field when creating an ad-hoc bill run. - For scheduled bill runs, if you do not specify any value for this field, the target date is the value of the `repeatFrom` field.
* @return targetDate
*/
@javax.annotation.Nullable
public LocalDate getTargetDate() {
return targetDate;
}
public void setTargetDate(LocalDate targetDate) {
this.targetDate = targetDate;
}
public CreateBillRunRequest targetDateMonthOffset(Integer targetDateMonthOffset) {
this.targetDateMonthOffset = targetDateMonthOffset;
return this;
}
/**
* The month offset of target date for this bill run based on run date, only valid for monthly scheduled bill runs. targetDateOffset and targetDateMonthOffset/targetDateDayOfMonth are mutually exclusive. targetDateMonthOffset and targetDateDayOfMonth coexist.
* @return targetDateMonthOffset
*/
@javax.annotation.Nullable
public Integer getTargetDateMonthOffset() {
return targetDateMonthOffset;
}
public void setTargetDateMonthOffset(Integer targetDateMonthOffset) {
this.targetDateMonthOffset = targetDateMonthOffset;
}
public CreateBillRunRequest targetDateDayOfMonth(Integer targetDateDayOfMonth) {
this.targetDateDayOfMonth = targetDateDayOfMonth;
return this;
}
/**
* The day of month of target date for this bill run, only valid for monthly scheduled bill runs. Specify any day of the month (1-31, where 31 = end-of-month). targetDateOffset and targetDateMonthOffset/targetDateDayOfMonth are mutually exclusive. targetDateMonthOffset and targetDateDayOfMonth coexist.
* minimum: 1
* maximum: 31
* @return targetDateDayOfMonth
*/
@javax.annotation.Nullable
public Integer getTargetDateDayOfMonth() {
return targetDateDayOfMonth;
}
public void setTargetDateDayOfMonth(Integer targetDateDayOfMonth) {
this.targetDateDayOfMonth = targetDateDayOfMonth;
}
public CreateBillRunRequest organizationLabels(List organizationLabels) {
this.organizationLabels = organizationLabels;
return this;
}
public CreateBillRunRequest addOrganizationLabelsItem(OrganizationLabel organizationLabelsItem) {
if (this.organizationLabels == null) {
this.organizationLabels = new ArrayList<>();
}
this.organizationLabels.add(organizationLabelsItem);
return this;
}
/**
* The organization(s) that the bill run is created for. For each item in the array, either the `organizationId` or the `organizationName` field is required. This field is only required when you have already turned on Multi-Org feature.
* @return organizationLabels
*/
@javax.annotation.Nullable
public List getOrganizationLabels() {
return organizationLabels;
}
public void setOrganizationLabels(List organizationLabels) {
this.organizationLabels = organizationLabels;
}
/**
* 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 CreateBillRunRequest instance itself
*/
public CreateBillRunRequest 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;
}
CreateBillRunRequest createBillRunRequest = (CreateBillRunRequest) o;
return Objects.equals(this.name, createBillRunRequest.name) &&
Objects.equals(this.batches, createBillRunRequest.batches) &&
Objects.equals(this.billCycleDay, createBillRunRequest.billCycleDay) &&
Objects.equals(this.billRunFilters, createBillRunRequest.billRunFilters) &&
Objects.equals(this.billRunType, createBillRunRequest.billRunType) &&
Objects.equals(this.chargeTypeToExclude, createBillRunRequest.chargeTypeToExclude) &&
Objects.equals(this.autoEmail, createBillRunRequest.autoEmail) &&
Objects.equals(this.autoPost, createBillRunRequest.autoPost) &&
Objects.equals(this.autoRenewal, createBillRunRequest.autoRenewal) &&
Objects.equals(this.noEmailForZeroAmountInvoice, createBillRunRequest.noEmailForZeroAmountInvoice) &&
Objects.equals(this.schedule, createBillRunRequest.schedule) &&
Objects.equals(this.invoiceDate, createBillRunRequest.invoiceDate) &&
Objects.equals(this.invoiceDateMonthOffset, createBillRunRequest.invoiceDateMonthOffset) &&
Objects.equals(this.invoiceDateDayOfMonth, createBillRunRequest.invoiceDateDayOfMonth) &&
Objects.equals(this.targetDate, createBillRunRequest.targetDate) &&
Objects.equals(this.targetDateMonthOffset, createBillRunRequest.targetDateMonthOffset) &&
Objects.equals(this.targetDateDayOfMonth, createBillRunRequest.targetDateDayOfMonth) &&
Objects.equals(this.organizationLabels, createBillRunRequest.organizationLabels)&&
Objects.equals(this.additionalProperties, createBillRunRequest.additionalProperties);
}
@Override
public int hashCode() {
return Objects.hash(name, batches, billCycleDay, billRunFilters, billRunType, chargeTypeToExclude, autoEmail, autoPost, autoRenewal, noEmailForZeroAmountInvoice, schedule, invoiceDate, invoiceDateMonthOffset, invoiceDateDayOfMonth, targetDate, targetDateMonthOffset, targetDateDayOfMonth, organizationLabels, additionalProperties);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class CreateBillRunRequest {\n");
sb.append(" name: ").append(toIndentedString(name)).append("\n");
sb.append(" batches: ").append(toIndentedString(batches)).append("\n");
sb.append(" billCycleDay: ").append(toIndentedString(billCycleDay)).append("\n");
sb.append(" billRunFilters: ").append(toIndentedString(billRunFilters)).append("\n");
sb.append(" billRunType: ").append(toIndentedString(billRunType)).append("\n");
sb.append(" chargeTypeToExclude: ").append(toIndentedString(chargeTypeToExclude)).append("\n");
sb.append(" autoEmail: ").append(toIndentedString(autoEmail)).append("\n");
sb.append(" autoPost: ").append(toIndentedString(autoPost)).append("\n");
sb.append(" autoRenewal: ").append(toIndentedString(autoRenewal)).append("\n");
sb.append(" noEmailForZeroAmountInvoice: ").append(toIndentedString(noEmailForZeroAmountInvoice)).append("\n");
sb.append(" schedule: ").append(toIndentedString(schedule)).append("\n");
sb.append(" invoiceDate: ").append(toIndentedString(invoiceDate)).append("\n");
sb.append(" invoiceDateMonthOffset: ").append(toIndentedString(invoiceDateMonthOffset)).append("\n");
sb.append(" invoiceDateDayOfMonth: ").append(toIndentedString(invoiceDateDayOfMonth)).append("\n");
sb.append(" targetDate: ").append(toIndentedString(targetDate)).append("\n");
sb.append(" targetDateMonthOffset: ").append(toIndentedString(targetDateMonthOffset)).append("\n");
sb.append(" targetDateDayOfMonth: ").append(toIndentedString(targetDateDayOfMonth)).append("\n");
sb.append(" organizationLabels: ").append(toIndentedString(organizationLabels)).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("name");
openapiFields.add("batches");
openapiFields.add("billCycleDay");
openapiFields.add("billRunFilters");
openapiFields.add("billRunType");
openapiFields.add("chargeTypeToExclude");
openapiFields.add("autoEmail");
openapiFields.add("autoPost");
openapiFields.add("autoRenewal");
openapiFields.add("noEmailForZeroAmountInvoice");
openapiFields.add("schedule");
openapiFields.add("invoiceDate");
openapiFields.add("invoiceDateMonthOffset");
openapiFields.add("invoiceDateDayOfMonth");
openapiFields.add("targetDate");
openapiFields.add("targetDateMonthOffset");
openapiFields.add("targetDateDayOfMonth");
openapiFields.add("organizationLabels");
// 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 CreateBillRunRequest
*/
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
if (jsonElement == null) {
if (!CreateBillRunRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in CreateBillRunRequest is not found in the empty JSON string", CreateBillRunRequest.openapiRequiredFields.toString()));
}
}
JsonObject jsonObj = jsonElement.getAsJsonObject();
if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !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()));
}
// ensure the optional json data is an array if present
if (jsonObj.get("batches") != null && !jsonObj.get("batches").isJsonNull() && !jsonObj.get("batches").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `batches` to be an array in the JSON string but got `%s`", jsonObj.get("batches").toString()));
}
if ((jsonObj.get("billCycleDay") != null && !jsonObj.get("billCycleDay").isJsonNull()) && !jsonObj.get("billCycleDay").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `billCycleDay` to be a primitive type in the JSON string but got `%s`", jsonObj.get("billCycleDay").toString()));
}
if (jsonObj.get("billRunFilters") != null && !jsonObj.get("billRunFilters").isJsonNull()) {
JsonArray jsonArraybillRunFilters = jsonObj.getAsJsonArray("billRunFilters");
if (jsonArraybillRunFilters != null) {
// ensure the json data is an array
if (!jsonObj.get("billRunFilters").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `billRunFilters` to be an array in the JSON string but got `%s`", jsonObj.get("billRunFilters").toString()));
}
// validate the optional field `billRunFilters` (array)
for (int i = 0; i < jsonArraybillRunFilters.size(); i++) {
BillRunFilter.validateJsonElement(jsonArraybillRunFilters.get(i));
};
}
}
if ((jsonObj.get("billRunType") != null && !jsonObj.get("billRunType").isJsonNull()) && !jsonObj.get("billRunType").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `billRunType` to be a primitive type in the JSON string but got `%s`", jsonObj.get("billRunType").toString()));
}
// validate the optional field `billRunType`
if (jsonObj.get("billRunType") != null && !jsonObj.get("billRunType").isJsonNull()) {
BillRunType.validateJsonElement(jsonObj.get("billRunType"));
}
// ensure the optional json data is an array if present
if (jsonObj.get("chargeTypeToExclude") != null && !jsonObj.get("chargeTypeToExclude").isJsonNull() && !jsonObj.get("chargeTypeToExclude").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `chargeTypeToExclude` to be an array in the JSON string but got `%s`", jsonObj.get("chargeTypeToExclude").toString()));
}
// validate the optional field `schedule`
if (jsonObj.get("schedule") != null && !jsonObj.get("schedule").isJsonNull()) {
BillRunSchedule.validateJsonElement(jsonObj.get("schedule"));
}
if (jsonObj.get("organizationLabels") != null && !jsonObj.get("organizationLabels").isJsonNull()) {
JsonArray jsonArrayorganizationLabels = jsonObj.getAsJsonArray("organizationLabels");
if (jsonArrayorganizationLabels != null) {
// ensure the json data is an array
if (!jsonObj.get("organizationLabels").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `organizationLabels` to be an array in the JSON string but got `%s`", jsonObj.get("organizationLabels").toString()));
}
// validate the optional field `organizationLabels` (array)
for (int i = 0; i < jsonArrayorganizationLabels.size(); i++) {
OrganizationLabel.validateJsonElement(jsonArrayorganizationLabels.get(i));
};
}
}
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@SuppressWarnings("unchecked")
@Override
public TypeAdapter create(Gson gson, TypeToken type) {
if (!CreateBillRunRequest.class.isAssignableFrom(type.getRawType())) {
return null; // this class only serializes 'CreateBillRunRequest' and its subtypes
}
final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
final TypeAdapter thisAdapter
= gson.getDelegateAdapter(this, TypeToken.get(CreateBillRunRequest.class));
return (TypeAdapter) new TypeAdapter() {
@Override
public void write(JsonWriter out, CreateBillRunRequest 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 CreateBillRunRequest read(JsonReader in) throws IOException {
JsonElement jsonElement = elementAdapter.read(in);
validateJsonElement(jsonElement);
JsonObject jsonObj = jsonElement.getAsJsonObject();
// store additional fields in the deserialized instance
CreateBillRunRequest 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 CreateBillRunRequest given an JSON string
*
* @param jsonString JSON string
* @return An instance of CreateBillRunRequest
* @throws IOException if the JSON string is invalid with respect to CreateBillRunRequest
*/
public static CreateBillRunRequest fromJson(String jsonString) throws IOException {
return JSON.getGson().fromJson(jsonString, CreateBillRunRequest.class);
}
/**
* Convert an instance of CreateBillRunRequest to an JSON string
*
* @return JSON string
*/
public String toJson() {
return JSON.getGson().toJson(this);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy