com.zuora.model.CreateUsageRequest 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 java.io.IOException;
import java.time.OffsetDateTime;
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;
/**
* CreateUsageRequest
*/
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.6.0")
public class CreateUsageRequest {
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_SUBSCRIPTION_ID = "SubscriptionId";
@SerializedName(SERIALIZED_NAME_SUBSCRIPTION_ID)
private String subscriptionId;
public static final String SERIALIZED_NAME_SUBSCRIPTION_NUMBER = "SubscriptionNumber";
@SerializedName(SERIALIZED_NAME_SUBSCRIPTION_NUMBER)
private String subscriptionNumber;
public static final String SERIALIZED_NAME_CHARGE_ID = "ChargeId";
@SerializedName(SERIALIZED_NAME_CHARGE_ID)
private String chargeId;
public static final String SERIALIZED_NAME_CHARGE_NUMBER = "ChargeNumber";
@SerializedName(SERIALIZED_NAME_CHARGE_NUMBER)
private String chargeNumber;
public static final String SERIALIZED_NAME_START_DATE_TIME = "StartDateTime";
@SerializedName(SERIALIZED_NAME_START_DATE_TIME)
private OffsetDateTime startDateTime;
public static final String SERIALIZED_NAME_END_DATE_TIME = "EndDateTime";
@SerializedName(SERIALIZED_NAME_END_DATE_TIME)
private OffsetDateTime endDateTime;
public static final String SERIALIZED_NAME_U_O_M = "UOM";
@SerializedName(SERIALIZED_NAME_U_O_M)
private String UOM;
public static final String SERIALIZED_NAME_QUANTITY = "Quantity";
@SerializedName(SERIALIZED_NAME_QUANTITY)
private Double quantity;
public static final String SERIALIZED_NAME_DESCRIPTION = "Description";
@SerializedName(SERIALIZED_NAME_DESCRIPTION)
private String description;
public CreateUsageRequest() {
}
public CreateUsageRequest accountId(String accountId) {
this.accountId = accountId;
return this;
}
/**
* The ID of the account associated with the usage data. This field is only required if no value is specified for the `AccountNumber` field. **Character limit**: 32 **Values**: a valid account ID.
* @return accountId
*/
@javax.annotation.Nullable
public String getAccountId() {
return accountId;
}
public void setAccountId(String accountId) {
this.accountId = accountId;
}
public CreateUsageRequest accountNumber(String accountNumber) {
this.accountNumber = accountNumber;
return this;
}
/**
* The number of the account associated with the usage data. This field is only required if no value is specified for the `AccountId` field. **Character limit**: 50 **Values**: a valid account number.
* @return accountNumber
*/
@javax.annotation.Nullable
public String getAccountNumber() {
return accountNumber;
}
public void setAccountNumber(String accountNumber) {
this.accountNumber = accountNumber;
}
public CreateUsageRequest subscriptionId(String subscriptionId) {
this.subscriptionId = subscriptionId;
return this;
}
/**
* The original ID of the subscription that contains the fees related to the usage data. The ID of a subscription might change when you create amendments to the subscription. It is good practice to use the unique subscription number that you can specify in the `SubscriptionNumber` field.
* @return subscriptionId
*/
@javax.annotation.Nullable
public String getSubscriptionId() {
return subscriptionId;
}
public void setSubscriptionId(String subscriptionId) {
this.subscriptionId = subscriptionId;
}
public CreateUsageRequest subscriptionNumber(String subscriptionNumber) {
this.subscriptionNumber = subscriptionNumber;
return this;
}
/**
* The unique identifier number of the subscription that contains the fees related to the usage data. It is good practice to use this field when creating usage records.
* @return subscriptionNumber
*/
@javax.annotation.Nullable
public String getSubscriptionNumber() {
return subscriptionNumber;
}
public void setSubscriptionNumber(String subscriptionNumber) {
this.subscriptionNumber = subscriptionNumber;
}
public CreateUsageRequest chargeId(String chargeId) {
this.chargeId = chargeId;
return this;
}
/**
* The OrginalId of the rate plan charge related to the usage record, e.g., `2c9081a03c63c94c013c6873357a0117` **Character limit**: 32 **Values**: a valid rate plan charge OriginalID.
* @return chargeId
*/
@javax.annotation.Nullable
public String getChargeId() {
return chargeId;
}
public void setChargeId(String chargeId) {
this.chargeId = chargeId;
}
public CreateUsageRequest chargeNumber(String chargeNumber) {
this.chargeNumber = chargeNumber;
return this;
}
/**
* A unique number for the rate plan charge related to the usage record. For example, C-00000007.
* @return chargeNumber
*/
@javax.annotation.Nullable
public String getChargeNumber() {
return chargeNumber;
}
public void setChargeNumber(String chargeNumber) {
this.chargeNumber = chargeNumber;
}
public CreateUsageRequest startDateTime(OffsetDateTime startDateTime) {
this.startDateTime = startDateTime;
return this;
}
/**
* The start date and time of a range of time when usage is tracked. Zuora uses this field value to determine the usage date. Unlike the `EndDateTime`, the `StartDateTime` field does affect usage calculation. **Character limit**: 29 **Values**: a valid date and time value
* @return startDateTime
*/
@javax.annotation.Nonnull
public OffsetDateTime getStartDateTime() {
return startDateTime;
}
public void setStartDateTime(OffsetDateTime startDateTime) {
this.startDateTime = startDateTime;
}
public CreateUsageRequest endDateTime(OffsetDateTime endDateTime) {
this.endDateTime = endDateTime;
return this;
}
/**
* The end date and time of a range of time when usage is tracked. Use this field for reporting; this field doesn't affect usage calculation. **Character limit**: 29 **Values**: a valid date and time value.
* @return endDateTime
*/
@javax.annotation.Nullable
public OffsetDateTime getEndDateTime() {
return endDateTime;
}
public void setEndDateTime(OffsetDateTime endDateTime) {
this.endDateTime = endDateTime;
}
public CreateUsageRequest UOM(String UOM) {
this.UOM = UOM;
return this;
}
/**
* Specifies the units to measure usage. Units of measure are configured in the web-based UI. Your values depend on your configuration in **Billing Settings**. **Character limit**: **Values**: a valid unit of measure
* @return UOM
*/
@javax.annotation.Nonnull
public String getUOM() {
return UOM;
}
public void setUOM(String UOM) {
this.UOM = UOM;
}
public CreateUsageRequest quantity(Double quantity) {
this.quantity = quantity;
return this;
}
/**
* Indicates the number of units used. **Character limit**: 16 **Values**: a valid decimal amount equal to or greater than 0
* @return quantity
*/
@javax.annotation.Nonnull
public Double getQuantity() {
return quantity;
}
public void setQuantity(Double quantity) {
this.quantity = quantity;
}
public CreateUsageRequest description(String description) {
this.description = description;
return this;
}
/**
* A description of the usage record.
* @return description
*/
@javax.annotation.Nullable
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
/**
* 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 CreateUsageRequest instance itself
*/
public CreateUsageRequest 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;
}
CreateUsageRequest createUsageRequest = (CreateUsageRequest) o;
return Objects.equals(this.accountId, createUsageRequest.accountId) &&
Objects.equals(this.accountNumber, createUsageRequest.accountNumber) &&
Objects.equals(this.subscriptionId, createUsageRequest.subscriptionId) &&
Objects.equals(this.subscriptionNumber, createUsageRequest.subscriptionNumber) &&
Objects.equals(this.chargeId, createUsageRequest.chargeId) &&
Objects.equals(this.chargeNumber, createUsageRequest.chargeNumber) &&
Objects.equals(this.startDateTime, createUsageRequest.startDateTime) &&
Objects.equals(this.endDateTime, createUsageRequest.endDateTime) &&
Objects.equals(this.UOM, createUsageRequest.UOM) &&
Objects.equals(this.quantity, createUsageRequest.quantity) &&
Objects.equals(this.description, createUsageRequest.description)&&
Objects.equals(this.additionalProperties, createUsageRequest.additionalProperties);
}
@Override
public int hashCode() {
return Objects.hash(accountId, accountNumber, subscriptionId, subscriptionNumber, chargeId, chargeNumber, startDateTime, endDateTime, UOM, quantity, description, additionalProperties);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class CreateUsageRequest {\n");
sb.append(" accountId: ").append(toIndentedString(accountId)).append("\n");
sb.append(" accountNumber: ").append(toIndentedString(accountNumber)).append("\n");
sb.append(" subscriptionId: ").append(toIndentedString(subscriptionId)).append("\n");
sb.append(" subscriptionNumber: ").append(toIndentedString(subscriptionNumber)).append("\n");
sb.append(" chargeId: ").append(toIndentedString(chargeId)).append("\n");
sb.append(" chargeNumber: ").append(toIndentedString(chargeNumber)).append("\n");
sb.append(" startDateTime: ").append(toIndentedString(startDateTime)).append("\n");
sb.append(" endDateTime: ").append(toIndentedString(endDateTime)).append("\n");
sb.append(" UOM: ").append(toIndentedString(UOM)).append("\n");
sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n");
sb.append(" description: ").append(toIndentedString(description)).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("AccountId");
openapiFields.add("AccountNumber");
openapiFields.add("SubscriptionId");
openapiFields.add("SubscriptionNumber");
openapiFields.add("ChargeId");
openapiFields.add("ChargeNumber");
openapiFields.add("StartDateTime");
openapiFields.add("EndDateTime");
openapiFields.add("UOM");
openapiFields.add("Quantity");
openapiFields.add("Description");
// a set of required properties/fields (JSON key names)
openapiRequiredFields = new HashSet();
openapiRequiredFields.add("StartDateTime");
openapiRequiredFields.add("UOM");
openapiRequiredFields.add("Quantity");
}
/**
* 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 CreateUsageRequest
*/
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
if (jsonElement == null) {
if (!CreateUsageRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in CreateUsageRequest is not found in the empty JSON string", CreateUsageRequest.openapiRequiredFields.toString()));
}
}
// check to make sure all required properties/fields are present in the JSON string
for (String requiredField : CreateUsageRequest.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("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("SubscriptionId") != null && !jsonObj.get("SubscriptionId").isJsonNull()) && !jsonObj.get("SubscriptionId").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `SubscriptionId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("SubscriptionId").toString()));
}
if ((jsonObj.get("SubscriptionNumber") != null && !jsonObj.get("SubscriptionNumber").isJsonNull()) && !jsonObj.get("SubscriptionNumber").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `SubscriptionNumber` to be a primitive type in the JSON string but got `%s`", jsonObj.get("SubscriptionNumber").toString()));
}
if ((jsonObj.get("ChargeId") != null && !jsonObj.get("ChargeId").isJsonNull()) && !jsonObj.get("ChargeId").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `ChargeId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("ChargeId").toString()));
}
if ((jsonObj.get("ChargeNumber") != null && !jsonObj.get("ChargeNumber").isJsonNull()) && !jsonObj.get("ChargeNumber").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `ChargeNumber` to be a primitive type in the JSON string but got `%s`", jsonObj.get("ChargeNumber").toString()));
}
if (!jsonObj.get("UOM").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `UOM` to be a primitive type in the JSON string but got `%s`", jsonObj.get("UOM").toString()));
}
if ((jsonObj.get("Description") != null && !jsonObj.get("Description").isJsonNull()) && !jsonObj.get("Description").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `Description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("Description").toString()));
}
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@SuppressWarnings("unchecked")
@Override
public TypeAdapter create(Gson gson, TypeToken type) {
if (!CreateUsageRequest.class.isAssignableFrom(type.getRawType())) {
return null; // this class only serializes 'CreateUsageRequest' and its subtypes
}
final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
final TypeAdapter thisAdapter
= gson.getDelegateAdapter(this, TypeToken.get(CreateUsageRequest.class));
return (TypeAdapter) new TypeAdapter() {
@Override
public void write(JsonWriter out, CreateUsageRequest 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 CreateUsageRequest read(JsonReader in) throws IOException {
JsonElement jsonElement = elementAdapter.read(in);
validateJsonElement(jsonElement);
JsonObject jsonObj = jsonElement.getAsJsonObject();
// store additional fields in the deserialized instance
CreateUsageRequest 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 CreateUsageRequest given an JSON string
*
* @param jsonString JSON string
* @return An instance of CreateUsageRequest
* @throws IOException if the JSON string is invalid with respect to CreateUsageRequest
*/
public static CreateUsageRequest fromJson(String jsonString) throws IOException {
return JSON.getGson().fromJson(jsonString, CreateUsageRequest.class);
}
/**
* Convert an instance of CreateUsageRequest to an JSON string
*
* @return JSON string
*/
public String toJson() {
return JSON.getGson().toJson(this);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy